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
32 33 34 35 36 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 32 def arrival_time return nil if departure_time.nil? || duration.nil? departure_time + duration.seconds end |
#convert_duration_to_seconds ⇒ Object
17 18 19 20 21 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 17 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
23 24 25 26 27 28 29 30 |
# File 'app/models/spree_cm_commissioner/trip.rb', line 23 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 |