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
#arrival_time ⇒ Object
44 45 46 47 48 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 44 def arrival_time return nil if departure_time.nil? || duration.nil? departure_time + duration.seconds end |
#convert_duration_to_seconds ⇒ Object
29 30 31 32 33 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 29 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
35 36 37 38 39 40 41 42 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 35 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 |