Class: StreetNames::Parser
- Inherits:
-
Object
- Object
- StreetNames::Parser
- Defined in:
- lib/street_names/parser.rb
Instance Attribute Summary collapse
-
#streets ⇒ Object
readonly
Returns the value of attribute streets.
Instance Method Summary collapse
-
#initialize(locale = LOCALE) ⇒ Parser
constructor
A new instance of Parser.
- #load_cities ⇒ Object
- #save! ⇒ Object
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
#streets ⇒ Object (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_cities ⇒ Object
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 |