Class: SpreeCmCommissioner::Transit::TripStopForm
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::Transit::TripStopForm
- Defined in:
- lib/spree_cm_commissioner/transit/trip_stop_form.rb
Instance Attribute Summary collapse
-
#allow_boarding ⇒ Object
Returns the value of attribute allow_boarding.
-
#allow_booking ⇒ Object
Returns the value of attribute allow_booking.
-
#allow_drop_off ⇒ Object
Returns the value of attribute allow_drop_off.
-
#allow_seat_selection ⇒ Object
Returns the value of attribute allow_seat_selection.
-
#board_to_trip_id ⇒ Object
Returns the value of attribute board_to_trip_id.
-
#departure_time ⇒ Object
Returns the value of attribute departure_time.
-
#duration_in_minutes ⇒ Object
Returns the value of attribute duration_in_minutes.
-
#location_id ⇒ Object
Returns the value of attribute location_id.
-
#offset_days ⇒ Object
Returns the value of attribute offset_days.
-
#route_type ⇒ Object
Returns the value of attribute route_type.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#stop_id ⇒ Object
Returns the value of attribute stop_id.
-
#stop_type ⇒ Object
Returns the value of attribute stop_type.
-
#vehicle_id ⇒ Object
Returns the value of attribute vehicle_id.
-
#vehicle_type_id ⇒ Object
Returns the value of attribute vehicle_type_id.
-
#vendor_id ⇒ Object
Returns the value of attribute vendor_id.
Instance Method Summary collapse
- #allow_boarding? ⇒ Boolean
- #allow_booking? ⇒ Boolean
- #allow_drop_off? ⇒ Boolean
- #allow_seat_selection? ⇒ Boolean
- #booking_editable? ⇒ Boolean
- #branch? ⇒ Boolean
- #duration_in_hours ⇒ Object
- #duration_in_hours_minutes ⇒ Object
-
#initialize(options = {}) ⇒ TripStopForm
constructor
A new instance of TripStopForm.
- #stop? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ TripStopForm
Returns a new instance of TripStopForm.
59 60 61 62 63 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 59 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#allow_boarding ⇒ Object
Returns the value of attribute allow_boarding.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def allow_boarding @allow_boarding end |
#allow_booking ⇒ Object
Returns the value of attribute allow_booking.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def allow_booking @allow_booking end |
#allow_drop_off ⇒ Object
Returns the value of attribute allow_drop_off.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def allow_drop_off @allow_drop_off end |
#allow_seat_selection ⇒ Object
Returns the value of attribute allow_seat_selection.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def allow_seat_selection @allow_seat_selection end |
#board_to_trip_id ⇒ Object
Returns the value of attribute board_to_trip_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def board_to_trip_id @board_to_trip_id end |
#departure_time ⇒ Object
Returns the value of attribute departure_time.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def departure_time @departure_time end |
#duration_in_minutes ⇒ Object
Returns the value of attribute duration_in_minutes.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def duration_in_minutes @duration_in_minutes end |
#location_id ⇒ Object
Returns the value of attribute location_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def location_id @location_id end |
#offset_days ⇒ Object
Returns the value of attribute offset_days.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def offset_days @offset_days end |
#route_type ⇒ Object
Returns the value of attribute route_type.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def route_type @route_type end |
#sequence ⇒ Object
Returns the value of attribute sequence.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def sequence @sequence end |
#stop_id ⇒ Object
Returns the value of attribute stop_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def stop_id @stop_id end |
#stop_type ⇒ Object
Returns the value of attribute stop_type.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def stop_type @stop_type end |
#vehicle_id ⇒ Object
Returns the value of attribute vehicle_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def vehicle_id @vehicle_id end |
#vehicle_type_id ⇒ Object
Returns the value of attribute vehicle_type_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def vehicle_type_id @vehicle_type_id end |
#vendor_id ⇒ Object
Returns the value of attribute vendor_id.
3 4 5 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 3 def vendor_id @vendor_id end |
Instance Method Details
#allow_boarding? ⇒ Boolean
65 66 67 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 65 def allow_boarding? ActiveModel::Type::Boolean.new.cast(allow_boarding) end |
#allow_booking? ⇒ Boolean
77 78 79 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 77 def allow_booking? ActiveModel::Type::Boolean.new.cast(allow_booking) end |
#allow_drop_off? ⇒ Boolean
69 70 71 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 69 def allow_drop_off? ActiveModel::Type::Boolean.new.cast(allow_drop_off) end |
#allow_seat_selection? ⇒ Boolean
73 74 75 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 73 def allow_seat_selection? ActiveModel::Type::Boolean.new.cast(allow_seat_selection) end |
#booking_editable? ⇒ Boolean
89 90 91 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 89 def booking_editable? branch? && board_to_trip_id.blank? end |
#branch? ⇒ Boolean
81 82 83 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 81 def branch? stop_type == 'branch' || stop_type == :branch end |
#duration_in_hours ⇒ Object
102 103 104 105 106 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 102 def duration_in_hours return nil if duration_in_minutes.blank? (duration_in_minutes.to_f / 60).round(2) end |
#duration_in_hours_minutes ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 93 def duration_in_hours_minutes return { hours: 0, minutes: 0 } if duration_in_minutes.blank? hours = (duration_in_minutes.to_f / 60).floor minutes = (duration_in_minutes.to_f % 60).round { hours: hours, minutes: minutes } end |
#stop? ⇒ Boolean
85 86 87 |
# File 'lib/spree_cm_commissioner/transit/trip_stop_form.rb', line 85 def stop? stop_type == 'stop' || stop_type == :stop end |