Class: Accuweather::Location

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Location.



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

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.



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

def city
  @city
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



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

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



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

def longitude
  @longitude
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

Instance Method Details

#==(other) ⇒ Object



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

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

#to_sObject



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

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