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.
3 4 5 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 3 def hours @hours end |
#minutes ⇒ Object
Returns the value of attribute minutes.
3 4 5 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 3 def minutes @minutes end |
#seconds ⇒ Object
Returns the value of attribute seconds.
3 4 5 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 3 def seconds @seconds end |
Instance Method Details
#arrival_time ⇒ Object
42 43 44 45 46 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 42 def arrival_time return nil if departure_time.nil? || duration.nil? departure_time + duration.seconds end |
#convert_duration_to_seconds ⇒ Object
27 28 29 30 31 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 27 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 |
#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 |