Class: Accuweather::Location::Parser

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

Instance Method Summary collapse

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

#citiesObject



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