Class: EdmTrain::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/edm_train/locations.rb

Overview

Location object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_location) ⇒ Location

Note:

This is not intended to be called directly

Returns a new instance of Location.

Parameters:

  • raw_location (Hash)

    the raw location from the API



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

#cityString (readonly)

the city (e.g. ‘Detroit’)

Returns:

  • (String)

    the current value of city



34
35
36
# File 'lib/edm_train/locations.rb', line 34

def city
  @city
end

#idInteger (readonly)

the location ID

Returns:

  • (Integer)

    the current value of id



34
35
36
# File 'lib/edm_train/locations.rb', line 34

def id
  @id
end

#latitudeFloat (readonly)

the latitude

Returns:

  • (Float)

    the current value of latitude



34
35
36
# File 'lib/edm_train/locations.rb', line 34

def latitude
  @latitude
end

the link to the location on EdmTrain

Returns:

  • (String)

    the current value of link



34
35
36
# File 'lib/edm_train/locations.rb', line 34

def link
  @link
end

#longitudeFloat (readonly)

the longitude

Returns:

  • (Float)

    the current value of longitude



34
35
36
# File 'lib/edm_train/locations.rb', line 34

def longitude
  @longitude
end

#stateString (readonly)

the state (e.g. ‘Michigan’)

Returns:

  • (String)

    the current value of state



34
35
36
# File 'lib/edm_train/locations.rb', line 34

def state
  @state
end

#state_codeString (readonly)

the state code (e.g. ‘MI’)

Returns:

  • (String)

    the current value of state_code



34
35
36
# File 'lib/edm_train/locations.rb', line 34

def state_code
  @state_code
end

Instance Method Details

#eventsArray<Event>

Returns all events for this location

Returns:



51
52
53
# File 'lib/edm_train/locations.rb', line 51

def events
  EdmTrain::Events.find(to_h)
end

#to_hHash

Returns a string representation of the location for event searching

Returns:

  • (Hash)


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