Class: CitibikeTrips::Station
- Inherits:
-
Object
- Object
- CitibikeTrips::Station
- Defined in:
- lib/citibike_trips/station.rb
Instance Attribute Summary collapse
-
#altitude ⇒ Object
readonly
Returns the value of attribute altitude.
-
#available_bikes ⇒ Object
readonly
Returns the value of attribute available_bikes.
-
#available_docks ⇒ Object
readonly
Returns the value of attribute available_docks.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#landmark ⇒ Object
readonly
Returns the value of attribute landmark.
-
#last_communication_time ⇒ Object
readonly
Returns the value of attribute last_communication_time.
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#postal_code ⇒ Object
readonly
Returns the value of attribute postal_code.
-
#status_key ⇒ Object
readonly
Returns the value of attribute status_key.
-
#status_value ⇒ Object
readonly
Returns the value of attribute status_value.
-
#street_address ⇒ Object
readonly
Returns the value of attribute street_address.
-
#street_address_array ⇒ Object
readonly
Returns the value of attribute street_address_array.
-
#test_station ⇒ Object
readonly
Returns the value of attribute test_station.
-
#total_docks ⇒ Object
readonly
Returns the value of attribute total_docks.
Instance Method Summary collapse
-
#initialize(data) ⇒ Station
constructor
A new instance of Station.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(data) ⇒ Station
Returns a new instance of Station.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/citibike_trips/station.rb', line 11 def initialize(data) data.each do |k,v| if v == '' data[k] = nil end end @id = data['id'] @name = data['stationName'] @available_docks = data['availableDocks'] @total_docks = data['totalDocks'] @available_bikes = data['availableBikes'] @latitude = data['latitude'] @longitude = data['longitude'] @location = data['location'] @altitude = data['altitude'] @street_address_array = [data['stAddress1']] if data['stAddress2'] @street_address_array << data['stAddress2'] end @street_address = @street_address_array.join(', ') @city = data['city'] || 'New York' @postal_code = data['postalCode'] @status_value = data['statusValue'] @status_key = data['statusKey'] @test_station = data['testStation'] @last_communication_time = data['lastCommunicationTime'] @landmark = data['landMark'] end |
Instance Attribute Details
#altitude ⇒ Object (readonly)
Returns the value of attribute altitude.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def altitude @altitude end |
#available_bikes ⇒ Object (readonly)
Returns the value of attribute available_bikes.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def available_bikes @available_bikes end |
#available_docks ⇒ Object (readonly)
Returns the value of attribute available_docks.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def available_docks @available_docks end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def city @city end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def id @id end |
#landmark ⇒ Object (readonly)
Returns the value of attribute landmark.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def landmark @landmark end |
#last_communication_time ⇒ Object (readonly)
Returns the value of attribute last_communication_time.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def last_communication_time @last_communication_time end |
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def latitude @latitude end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def location @location end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def longitude @longitude end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def name @name end |
#postal_code ⇒ Object (readonly)
Returns the value of attribute postal_code.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def postal_code @postal_code end |
#status_key ⇒ Object (readonly)
Returns the value of attribute status_key.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def status_key @status_key end |
#status_value ⇒ Object (readonly)
Returns the value of attribute status_value.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def status_value @status_value end |
#street_address ⇒ Object (readonly)
Returns the value of attribute street_address.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def street_address @street_address end |
#street_address_array ⇒ Object (readonly)
Returns the value of attribute street_address_array.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def street_address_array @street_address_array end |
#test_station ⇒ Object (readonly)
Returns the value of attribute test_station.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def test_station @test_station end |
#total_docks ⇒ Object (readonly)
Returns the value of attribute total_docks.
4 5 6 |
# File 'lib/citibike_trips/station.rb', line 4 def total_docks @total_docks end |
Instance Method Details
#to_json(*a) ⇒ Object
39 40 41 |
# File 'lib/citibike_trips/station.rb', line 39 def to_json(*a) Hash[instance_variables.collect{|i| [i[1..-1], instance_variable_get(i)]}].to_json(*a) end |