Class: Accuweather::Location::Parser
- Inherits:
-
Object
- Object
- Accuweather::Location::Parser
- Defined in:
- lib/accuweather/location/parser.rb
Instance Method Summary collapse
- #cities ⇒ Object
-
#initialize(response) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(response) ⇒ Parser
Returns a new instance of Parser.
4 5 6 |
# File 'lib/accuweather/location/parser.rb', line 4 def initialize(response) @doc = Nokogiri::XML.parse(response) end |
Instance Method Details
#cities ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/accuweather/location/parser.rb', line 8 def cities @doc.css('location').map do |location| Accuweather::Location::City.new(id: location.attr('location'), city: location.attr('city'), state: location.attr('state'), latitude: location.attr('latitude'), longitude: location.attr('longitude')) end end |