Class: CitibikeTrips::Trip
- Inherits:
-
Object
- Object
- CitibikeTrips::Trip
- Defined in:
- lib/citibike_trips/trip.rb
Instance Attribute Summary collapse
-
#end_station ⇒ Object
readonly
Returns the value of attribute end_station.
-
#end_timestamp ⇒ Object
readonly
Returns the value of attribute end_timestamp.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#start_station ⇒ Object
readonly
Returns the value of attribute start_station.
-
#start_timestamp ⇒ Object
readonly
Returns the value of attribute start_timestamp.
Instance Method Summary collapse
-
#initialize(id, start_station, end_station, start_timestamp, end_timestamp) ⇒ Trip
constructor
A new instance of Trip.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(id, start_station, end_station, start_timestamp, end_timestamp) ⇒ Trip
Returns a new instance of Trip.
6 7 8 9 10 11 12 13 |
# File 'lib/citibike_trips/trip.rb', line 6 def initialize(id, start_station, end_station, , ) @id = id stations = CitibikeTrips::Stations.new @start_station = stations[start_station.to_i] @end_station = stations[end_station.to_i] @start_timestamp = Time.at(.to_i) @end_timestamp = Time.at(.to_i) end |
Instance Attribute Details
#end_station ⇒ Object (readonly)
Returns the value of attribute end_station.
4 5 6 |
# File 'lib/citibike_trips/trip.rb', line 4 def end_station @end_station end |
#end_timestamp ⇒ Object (readonly)
Returns the value of attribute end_timestamp.
4 5 6 |
# File 'lib/citibike_trips/trip.rb', line 4 def @end_timestamp end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/citibike_trips/trip.rb', line 4 def id @id end |
#start_station ⇒ Object (readonly)
Returns the value of attribute start_station.
4 5 6 |
# File 'lib/citibike_trips/trip.rb', line 4 def start_station @start_station end |
#start_timestamp ⇒ Object (readonly)
Returns the value of attribute start_timestamp.
4 5 6 |
# File 'lib/citibike_trips/trip.rb', line 4 def @start_timestamp end |
Instance Method Details
#to_json(*a) ⇒ Object
15 16 17 |
# File 'lib/citibike_trips/trip.rb', line 15 def to_json(*a) Hash[instance_variables.collect{|i| [i[1..-1], instance_variable_get(i)]}].to_json(*a) end |