Class: Omnizip::Models::ETAResult
- Inherits:
-
Object
- Object
- Omnizip::Models::ETAResult
- Defined in:
- lib/omnizip/models/eta_result.rb
Overview
Model representing an ETA (Estimated Time to Arrival) calculation result.
This class encapsulates the result of ETA calculations, including seconds remaining, formatted time string, and confidence interval.
Instance Attribute Summary collapse
-
#confidence_lower ⇒ Object
Returns the value of attribute confidence_lower.
-
#confidence_upper ⇒ Object
Returns the value of attribute confidence_upper.
-
#formatted ⇒ Object
Returns the value of attribute formatted.
-
#seconds_remaining ⇒ Object
Returns the value of attribute seconds_remaining.
Instance Method Summary collapse
-
#confidence_interval ⇒ Array<Float>
Get confidence interval as array.
-
#reliable? ⇒ Boolean
Check if ETA is reliable (confidence interval is reasonable).
- #to_h ⇒ Object
Instance Attribute Details
#confidence_lower ⇒ Object
Returns the value of attribute confidence_lower.
14 15 16 |
# File 'lib/omnizip/models/eta_result.rb', line 14 def confidence_lower @confidence_lower end |
#confidence_upper ⇒ Object
Returns the value of attribute confidence_upper.
14 15 16 |
# File 'lib/omnizip/models/eta_result.rb', line 14 def confidence_upper @confidence_upper end |
#formatted ⇒ Object
Returns the value of attribute formatted.
14 15 16 |
# File 'lib/omnizip/models/eta_result.rb', line 14 def formatted @formatted end |
#seconds_remaining ⇒ Object
Returns the value of attribute seconds_remaining.
14 15 16 |
# File 'lib/omnizip/models/eta_result.rb', line 14 def seconds_remaining @seconds_remaining end |
Instance Method Details
#confidence_interval ⇒ Array<Float>
Get confidence interval as array
20 21 22 |
# File 'lib/omnizip/models/eta_result.rb', line 20 def confidence_interval [confidence_lower, confidence_upper] end |
#reliable? ⇒ Boolean
Check if ETA is reliable (confidence interval is reasonable)
27 28 29 30 31 32 33 34 |
# File 'lib/omnizip/models/eta_result.rb', line 27 def reliable? unless seconds_remaining && confidence_lower && confidence_upper return false end range = confidence_upper - confidence_lower range < (seconds_remaining * 0.5) end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/omnizip/models/eta_result.rb', line 36 def to_h { seconds_remaining: @seconds_remaining, formatted: @formatted, confidence_lower: @confidence_lower, confidence_upper: @confidence_upper, }.compact end |