Class: JapanETC::DatabaseProvider::PastDatabase

Inherits:
Base
  • Object
show all
Defined in:
lib/japan_etc/database_provider/past_database.rb

Overview

Instance Method Summary collapse

Methods inherited from Base

#source_url

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

#csvObject



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_tollboothsObject



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

#rowsObject



39
40
41
# File 'lib/japan_etc/database_provider/past_database.rb', line 39

def rows
  CSV.parse(csv, headers: :first_row)
end

#source_idObject



12
13
14
# File 'lib/japan_etc/database_provider/past_database.rb', line 12

def source_id
  'PastDatabase'
end