Class: Data::Location

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

Overview

A simple Location class

Used to store location information about the station that gave the measurement data for a weather query, or the location that was queried

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cityObject

Returns the value of attribute city.



11
12
13
# File 'lib/barometer/data/location.rb', line 11

def city
  @city
end

#countryObject

Returns the value of attribute country.



12
13
14
# File 'lib/barometer/data/location.rb', line 12

def country
  @country
end

#country_codeObject

Returns the value of attribute country_code.



12
13
14
# File 'lib/barometer/data/location.rb', line 12

def country_code
  @country_code
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/barometer/data/location.rb', line 11

def id
  @id
end

#latitudeObject

Returns the value of attribute latitude.



13
14
15
# File 'lib/barometer/data/location.rb', line 13

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



13
14
15
# File 'lib/barometer/data/location.rb', line 13

def longitude
  @longitude
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/barometer/data/location.rb', line 11

def name
  @name
end

#state_codeObject

Returns the value of attribute state_code.



12
13
14
# File 'lib/barometer/data/location.rb', line 12

def state_code
  @state_code
end

#state_nameObject

Returns the value of attribute state_name.



12
13
14
# File 'lib/barometer/data/location.rb', line 12

def state_name
  @state_name
end

#zip_codeObject

Returns the value of attribute zip_code.



12
13
14
# File 'lib/barometer/data/location.rb', line 12

def zip_code
  @zip_code
end

Instance Method Details

#coordinatesObject



15
16
17
# File 'lib/barometer/data/location.rb', line 15

def coordinates
  [@latitude, @longitude].join(',')
end

#to_sObject



19
20
21
22
# File 'lib/barometer/data/location.rb', line 19

def to_s
  [@name, @city, @state_name || @state_cocde,
    @country || @country_code].compact.join(', ')
end