Class: SpreeCmCommissioner::Trip
- Defined in:
- app/models/spree_cm_commissioner/trip.rb
Instance Attribute Summary collapse
-
#hours ⇒ Object
Returns the value of attribute hours.
-
#minutes ⇒ Object
Returns the value of attribute minutes.
-
#seconds ⇒ Object
Returns the value of attribute seconds.
Instance Method Summary collapse
Instance Attribute Details
#hours ⇒ Object
Returns the value of attribute hours.
4 5 6 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 4 def hours @hours end |
#minutes ⇒ Object
Returns the value of attribute minutes.
4 5 6 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 4 def minutes @minutes end |
#seconds ⇒ Object
Returns the value of attribute seconds.
4 5 6 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 4 def seconds @seconds end |
Instance Method Details
#convert_duration_to_seconds ⇒ Object
22 23 24 25 26 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 22 def convert_duration_to_seconds return if hours.blank? && minutes.blank? && seconds.blank? self.duration = (hours.to_i * 3600) + (minutes.to_i * 60) + seconds.to_i end |
#create_trip_stops ⇒ Object
28 29 30 31 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 28 def create_trip_stops trip_stops.create(stop_type: :boarding, stop_id: origin_id) trip_stops.create(stop_type: :drop_off, stop_id: destination_id) end |
#duration_in_hms ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 33 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 |