Class: Categories
- Inherits:
-
Object
- Object
- Categories
- Defined in:
- lib/data/sr24/csv_to_muchidata.rb
Instance Method Summary collapse
- #build_hash ⇒ Object
- #code_numbers ⇒ Object
-
#initialize ⇒ Categories
constructor
A new instance of Categories.
- #name_from_code(code) ⇒ Object
- #names ⇒ Object
Constructor Details
#initialize ⇒ Categories
Returns a new instance of Categories.
17 18 19 20 |
# File 'lib/data/sr24/csv_to_muchidata.rb', line 17 def initialize @hash= Hash.new build_hash end |
Instance Method Details
#build_hash ⇒ Object
22 23 24 25 26 27 |
# File 'lib/data/sr24/csv_to_muchidata.rb', line 22 def build_hash CSV.read("./FD_GROUP.csv").each do |line| rows = line.first.split("^") @hash[rows[0]] = rows[1] end end |
#code_numbers ⇒ Object
33 34 35 |
# File 'lib/data/sr24/csv_to_muchidata.rb', line 33 def code_numbers @hash.keys end |
#name_from_code(code) ⇒ Object
37 38 39 |
# File 'lib/data/sr24/csv_to_muchidata.rb', line 37 def name_from_code(code) @hash[code].downcase.gsub(" ", "-") end |
#names ⇒ Object
29 30 31 |
# File 'lib/data/sr24/csv_to_muchidata.rb', line 29 def names @hash.values.map{|c| c.downcase.gsub(" ", "_") } end |