Class: SpreeCmCommissioner::TripResult
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::TripResult
- Defined in:
- lib/spree_cm_commissioner/trip_result.rb
Instance Attribute Summary collapse
-
#departure_time ⇒ Object
Returns the value of attribute departure_time.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#destination_id ⇒ Object
Returns the value of attribute destination_id.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#origin_id ⇒ Object
Returns the value of attribute origin_id.
-
#route_name ⇒ Object
Returns the value of attribute route_name.
-
#short_name ⇒ Object
Returns the value of attribute short_name.
-
#total_seats ⇒ Object
Returns the value of attribute total_seats.
-
#total_sold ⇒ Object
Returns the value of attribute total_sold.
-
#trip_id ⇒ Object
Returns the value of attribute trip_id.
-
#vehicle_id ⇒ Object
Returns the value of attribute vehicle_id.
-
#vendor_id ⇒ Object
Returns the value of attribute vendor_id.
-
#vendor_name ⇒ Object
Returns the value of attribute vendor_name.
Instance Method Summary collapse
- #arrival_time ⇒ Object
- #duration_in_hms ⇒ Object
-
#initialize(options = {}) ⇒ TripResult
constructor
A new instance of TripResult.
- #remaining_seats ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TripResult
Returns a new instance of TripResult.
8 9 10 11 12 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 8 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#departure_time ⇒ Object
Returns the value of attribute departure_time.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def departure_time @departure_time end |
#destination ⇒ Object
Returns the value of attribute destination.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def destination @destination end |
#destination_id ⇒ Object
Returns the value of attribute destination_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def destination_id @destination_id end |
#duration ⇒ Object
Returns the value of attribute duration.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def duration @duration end |
#origin ⇒ Object
Returns the value of attribute origin.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def origin @origin end |
#origin_id ⇒ Object
Returns the value of attribute origin_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def origin_id @origin_id end |
#route_name ⇒ Object
Returns the value of attribute route_name.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def route_name @route_name end |
#short_name ⇒ Object
Returns the value of attribute short_name.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def short_name @short_name end |
#total_seats ⇒ Object
Returns the value of attribute total_seats.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def total_seats @total_seats end |
#total_sold ⇒ Object
Returns the value of attribute total_sold.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def total_sold @total_sold end |
#trip_id ⇒ Object
Returns the value of attribute trip_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def trip_id @trip_id end |
#vehicle_id ⇒ Object
Returns the value of attribute vehicle_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def vehicle_id @vehicle_id end |
#vendor_id ⇒ Object
Returns the value of attribute vendor_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def vendor_id @vendor_id end |
#vendor_name ⇒ Object
Returns the value of attribute vendor_name.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def vendor_name @vendor_name end |
Instance Method Details
#arrival_time ⇒ Object
18 19 20 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 18 def arrival_time (departure_time.to_time + duration.to_i.seconds).strftime('%H:%M') end |
#duration_in_hms ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 22 def duration_in_hms return 0 if duration.nil? hours = duration / 3600 minutes = (duration % 3600) / 60 seconds = duration % 60 "#{hours}h #{minutes}m #{seconds}s" end |
#remaining_seats ⇒ Object
14 15 16 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 14 def remaining_seats total_seats - total_sold end |