Class: EdmTrain::Location
- Inherits:
-
Object
- Object
- EdmTrain::Location
- Defined in:
- lib/edm_train/locations.rb
Overview
Location object
Instance Attribute Summary collapse
-
#city ⇒ String
readonly
the city (e.g. ‘Detroit’).
-
#id ⇒ Integer
readonly
the location ID.
-
#latitude ⇒ Float
readonly
the latitude.
-
#link ⇒ String
readonly
the link to the location on EdmTrain.
-
#longitude ⇒ Float
readonly
the longitude.
-
#state ⇒ String
readonly
the state (e.g. ‘Michigan’).
-
#state_code ⇒ String
readonly
the state code (e.g. ‘MI’).
Instance Method Summary collapse
-
#events ⇒ Array<Event>
Returns all events for this location.
-
#initialize(raw_location) ⇒ Location
constructor
A new instance of Location.
-
#to_h ⇒ Hash
Returns a string representation of the location for event searching.
Constructor Details
#initialize(raw_location) ⇒ Location
Note:
This is not intended to be called directly
Returns a new instance of Location.
39 40 41 42 43 44 45 46 47 |
# File 'lib/edm_train/locations.rb', line 39 def initialize(raw_location) @id = raw_location['id'] @city = raw_location['city'] @state = raw_location['state'] @state_code = raw_location['stateCode'] @latitude = raw_location['latitude'] @longitude = raw_location['longitude'] @link = raw_location['link'] end |
Instance Attribute Details
#city ⇒ String (readonly)
the city (e.g. ‘Detroit’)
34 35 36 |
# File 'lib/edm_train/locations.rb', line 34 def city @city end |
#id ⇒ Integer (readonly)
the location ID
34 35 36 |
# File 'lib/edm_train/locations.rb', line 34 def id @id end |
#latitude ⇒ Float (readonly)
the latitude
34 35 36 |
# File 'lib/edm_train/locations.rb', line 34 def latitude @latitude end |
#link ⇒ String (readonly)
the link to the location on EdmTrain
34 35 36 |
# File 'lib/edm_train/locations.rb', line 34 def link @link end |
#longitude ⇒ Float (readonly)
the longitude
34 35 36 |
# File 'lib/edm_train/locations.rb', line 34 def longitude @longitude end |
#state ⇒ String (readonly)
the state (e.g. ‘Michigan’)
34 35 36 |
# File 'lib/edm_train/locations.rb', line 34 def state @state end |
#state_code ⇒ String (readonly)
the state code (e.g. ‘MI’)
34 35 36 |
# File 'lib/edm_train/locations.rb', line 34 def state_code @state_code end |
Instance Method Details
#events ⇒ Array<Event>
Returns all events for this location
51 52 53 |
# File 'lib/edm_train/locations.rb', line 51 def events EdmTrain::Events.find(to_h) end |
#to_h ⇒ Hash
Returns a string representation of the location for event searching
57 58 59 60 61 62 63 64 |
# File 'lib/edm_train/locations.rb', line 57 def to_h { city: @city, state: @state, latitude: @latitude, longitude: @longitude } end |