Class: Syukujitsu::CsvLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/syukujitsu/csv_loader.rb

Instance Method Summary collapse

Instance Method Details

#load(csv_path) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/syukujitsu/csv_loader.rb', line 8

def load(csv_path)
  entities = {}
  CSV.foreach(csv_path, headers: true, encoding: "UTF-8") do |row|
    date = Date.strptime(row[0], "%Y/%m/%d")
    entities[date] = Entity.new(date: date, name: row[1]).freeze
  end
  entities.freeze
end