Here is the code
这是代码
class Tech
attr_reader :content, :tech_hash
@tech_hash = Hash.new(0)
def initialize(content)
@content = content
showTech(content)
end
def showTech(content)
content.split.each do |word|
@tech_hash[word] += 1
end
@tech_hash = @tech_hash.sort_by{|k,v| -v}.to_h
p @tech_hash
end
end
class Digital
def analyze()
File.foreach('test.txt') do |content|
ob = Tech.new(content)
end
end
end
digi = Digital.new()
digi.analyze()
class Tech
attr_rea