Class: CitibikeTrips::Station

Inherits:
Object
  • Object
show all
Defined in:
lib/citibike_trips/station.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#altitudeObject (readonly)

Returns the value of attribute altitude.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def altitude
  @altitude
end

#available_bikesObject (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_docksObject (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

#cityObject (readonly)

Returns the value of attribute city.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def city
  @city
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def id
  @id
end

#landmarkObject (readonly)

Returns the value of attribute landmark.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def landmark
  @landmark
end

#last_communication_timeObject (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

#latitudeObject (readonly)

Returns the value of attribute latitude.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def latitude
  @latitude
end

#locationObject (readonly)

Returns the value of attribute location.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def location
  @location
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/citibike_trips/station.rb', line 4

def name
  @name
end

#postal_codeObject (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_keyObject (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_valueObject (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_addressObject (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_arrayObject (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_stationObject (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_docksObject (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