Class: JapanETC::DatabaseProvider::PastDatabase
- Defined in:
- lib/japan_etc/database_provider/past_database.rb
Overview
Instance Method Summary collapse
- #create_tollbooth_from_row(row) ⇒ Object
- #csv ⇒ Object
- #fetch_tollbooths ⇒ Object
- #rows ⇒ Object
- #source_id ⇒ Object
Methods inherited from Base
Instance Method Details
#create_tollbooth_from_row(row) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/japan_etc/database_provider/past_database.rb', line 22 def create_tollbooth_from_row(row) identifier = Tollbooth::Identifier.from(row[0]) road = Road.new(row[1], row[2]) Tollbooth.new( identifier: identifier, road: road, name: row[3], direction: row[4], entrance_or_exit: row[5], note: row[6], source: source_id, priority: -1 ) end |
#csv ⇒ Object
43 44 45 46 |
# File 'lib/japan_etc/database_provider/past_database.rb', line 43 def csv path = File.join(__dir__, 'past_database.csv') File.read(path) end |
#fetch_tollbooths ⇒ Object
16 17 18 19 20 |
# File 'lib/japan_etc/database_provider/past_database.rb', line 16 def fetch_tollbooths rows.map do |row| create_tollbooth_from_row(row) end end |
#rows ⇒ Object
39 40 41 |
# File 'lib/japan_etc/database_provider/past_database.rb', line 39 def rows CSV.parse(csv, headers: :first_row) end |
#source_id ⇒ Object
12 13 14 |
# File 'lib/japan_etc/database_provider/past_database.rb', line 12 def source_id 'PastDatabase' end |