Class: Accuweather::Location::City

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, city:, state:, latitude:, longitude:) ⇒ City

Returns a new instance of City.



6
7
8
9
10
11
12
# File 'lib/accuweather/location/city.rb', line 6

def initialize(id:, city:, state:, latitude:, longitude:)
  @id = id
  @city = city
  @state = state
  @latitude = latitude
  @longitude = longitude
end

Instance Attribute Details

#cityObject (readonly)

Returns the value of attribute city.



4
5
6
# File 'lib/accuweather/location/city.rb', line 4

def city
  @city
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/accuweather/location/city.rb', line 4

def id
  @id
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



4
5
6
# File 'lib/accuweather/location/city.rb', line 4

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



4
5
6
# File 'lib/accuweather/location/city.rb', line 4

def longitude
  @longitude
end

#stateObject (readonly)

Returns the value of attribute state.



4
5
6
# File 'lib/accuweather/location/city.rb', line 4

def state
  @state
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/accuweather/location/city.rb', line 14

def ==(other)
  id == other.id &&
    city == other.city &&
    state == other.state &&
    latitude == other.latitude &&
    longitude == other.longitude
rescue NoMethodError
  false
end

#to_sObject



24
25
26
# File 'lib/accuweather/location/city.rb', line 24

def to_s
  "id: #{id}, city: #{city}, state: #{state}, latitude: #{latitude}, longitude: #{longitude}"
end