Class: SpreeCmCommissioner::TripResult
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::TripResult
- Defined in:
- lib/spree_cm_commissioner/trip_result.rb
Instance Attribute Summary collapse
-
#allow_seat_selection ⇒ Object
Returns the value of attribute allow_seat_selection.
-
#amenities ⇒ Object
Returns the value of attribute amenities.
-
#boarding ⇒ Object
Returns the value of attribute boarding.
-
#compare_at_amount ⇒ Object
Returns the value of attribute compare_at_amount.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#departure_time ⇒ Object
Returns the value of attribute departure_time.
-
#destination_place ⇒ Object
Returns the value of attribute destination_place.
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#drop_off ⇒ Object
Returns the value of attribute drop_off.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#id ⇒ Object
Returns the value of attribute id.
-
#max_capacity ⇒ Object
Returns the value of attribute max_capacity.
-
#origin_place ⇒ Object
Returns the value of attribute origin_place.
-
#price ⇒ Object
Returns the value of attribute price.
-
#product_id ⇒ Object
Returns the value of attribute product_id.
-
#quantity_available ⇒ Object
Returns the value of attribute quantity_available.
-
#route_type ⇒ Object
Returns the value of attribute route_type.
-
#vehicle ⇒ Object
Returns the value of attribute vehicle.
-
#vehicle_id ⇒ Object
Returns the value of attribute vehicle_id.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
-
#vendor_id ⇒ Object
Returns the value of attribute vendor_id.
Instance Method Summary collapse
- #amenity_ids ⇒ Object
- #arrival_time ⇒ Object
- #duration_in_hms ⇒ Object
-
#initialize(options = {}) ⇒ TripResult
constructor
A new instance of TripResult.
- #total_sold ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TripResult
Returns a new instance of TripResult.
9 10 11 12 13 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 9 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#allow_seat_selection ⇒ Object
Returns the value of attribute allow_seat_selection.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def allow_seat_selection @allow_seat_selection end |
#amenities ⇒ Object
Returns the value of attribute amenities.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def amenities @amenities end |
#boarding ⇒ Object
Returns the value of attribute boarding.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def boarding @boarding end |
#compare_at_amount ⇒ Object
Returns the value of attribute compare_at_amount.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def compare_at_amount @compare_at_amount end |
#currency ⇒ Object
Returns the value of attribute currency.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def currency @currency end |
#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_place ⇒ Object
Returns the value of attribute destination_place.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def destination_place @destination_place end |
#distance ⇒ Object
Returns the value of attribute distance.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def distance @distance end |
#drop_off ⇒ Object
Returns the value of attribute drop_off.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def drop_off @drop_off 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 |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def id @id end |
#max_capacity ⇒ Object
Returns the value of attribute max_capacity.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def max_capacity @max_capacity end |
#origin_place ⇒ Object
Returns the value of attribute origin_place.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def origin_place @origin_place end |
#price ⇒ Object
Returns the value of attribute price.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def price @price end |
#product_id ⇒ Object
Returns the value of attribute product_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def product_id @product_id end |
#quantity_available ⇒ Object
Returns the value of attribute quantity_available.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def quantity_available @quantity_available end |
#route_type ⇒ Object
Returns the value of attribute route_type.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def route_type @route_type end |
#vehicle ⇒ Object
Returns the value of attribute vehicle.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def vehicle @vehicle 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 ⇒ Object
Returns the value of attribute vendor.
3 4 5 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 3 def vendor @vendor 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 |
Instance Method Details
#amenity_ids ⇒ Object
21 22 23 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 21 def amenity_ids amenities&.map(&:id) || [] end |
#arrival_time ⇒ Object
34 35 36 37 38 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 34 def arrival_time return nil if departure_time.nil? || duration.nil? departure_time + duration.seconds end |
#duration_in_hms ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 25 def duration_in_hms return { hours: 0, minutes: 0, seconds: 0 } if duration.nil? hours = duration / 3600 minutes = (duration % 3600) / 60 seconds = duration % 60 { hours: hours, minutes: minutes, seconds: seconds } end |
#total_sold ⇒ Object
15 16 17 18 19 |
# File 'lib/spree_cm_commissioner/trip_result.rb', line 15 def total_sold return if max_capacity.nil? || quantity_available.nil? max_capacity - quantity_available end |