Class: StreetNames::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/street_names/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale = LOCALE) ⇒ Parser

Returns a new instance of Parser.



7
8
9
# File 'lib/street_names/parser.rb', line 7

def initialize locale=LOCALE
  @locale = locale
end

Instance Attribute Details

#streetsObject (readonly)

Returns the value of attribute streets.



5
6
7
# File 'lib/street_names/parser.rb', line 5

def streets
  @streets
end

Instance Method Details

#load_citiesObject



11
12
13
14
15
# File 'lib/street_names/parser.rb', line 11

def load_cities
  @streets ||= CITIES.each_value.map do |city|
    spreadsheet.worksheets[city].map {|parameters| Street.new parameters }
  end.inject(:+)
end

#save!Object



17
18
19
20
# File 'lib/street_names/parser.rb', line 17

def save!
  db = StreetNames::Database.new @locale
  db.save! :streets => @streets.map(&:to_hash)
end