Class: Omnizip::Models::ETAResult

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#confidence_lowerObject

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_upperObject

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

#formattedObject

Returns the value of attribute formatted.



14
15
16
# File 'lib/omnizip/models/eta_result.rb', line 14

def formatted
  @formatted
end

#seconds_remainingObject

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_intervalArray<Float>

Get confidence interval as array

Returns:

  • (Array<Float>)

    [lower, upper] bounds in seconds



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)

Returns:

  • (Boolean)

    true if confidence interval is within 50% of estimate



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_hObject



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