Class: BusTime::Prediction

Inherits:
Object
  • Object
show all
Defined in:
lib/bus_time/prediction.rb

Overview

Service bus stop prediction handling, including prediction retrieval via BusTime::Api

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_id, direction, stop_id, arrival_minutes, **opts) ⇒ Prediction

Returns a new instance of Prediction.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bus_time/prediction.rb', line 11

def initialize(route_id, direction, stop_id, arrival_minutes, **opts)
  @route_id = route_id
  @stop_id = stop_id
  @direction = direction
  @arrival_minutes = arrival_minutes

  @trip_id = opts[:trip_id]
  @vehicle_id = opts[:vehicle_id]

  @destination = opts[:destination]
  @stop_name = opts[:stop_name]

  @arrives_at = opts[:arrives_at]
  @prediction_type = opts[:prediction_type] || "arrival"
  @delayed = opts[:delayed] || false

  @generated_at = opts[:generated_at] || DateTime.now
end

Instance Attribute Details

#arrival_minutesObject (readonly)

Returns the value of attribute arrival_minutes.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def arrival_minutes
  @arrival_minutes
end

#arrives_atObject (readonly)

Returns the value of attribute arrives_at.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def arrives_at
  @arrives_at
end

#delayedObject (readonly)

Returns the value of attribute delayed.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def delayed
  @delayed
end

#destinationObject (readonly)

Returns the value of attribute destination.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def destination
  @destination
end

#directionObject (readonly)

Returns the value of attribute direction.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def direction
  @direction
end

#generated_atObject (readonly)

Returns the value of attribute generated_at.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def generated_at
  @generated_at
end

#prediction_typeObject (readonly)

Returns the value of attribute prediction_type.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def prediction_type
  @prediction_type
end

#route_idObject (readonly)

Returns the value of attribute route_id.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def route_id
  @route_id
end

#stop_idObject (readonly)

Returns the value of attribute stop_id.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def stop_id
  @stop_id
end

#stop_nameObject (readonly)

Returns the value of attribute stop_name.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def stop_name
  @stop_name
end

#timeObject (readonly)

Returns the value of attribute time.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def time
  @time
end

#trip_idObject (readonly)

Returns the value of attribute trip_id.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def trip_id
  @trip_id
end

#vehicle_idObject (readonly)

Returns the value of attribute vehicle_id.



6
7
8
# File 'lib/bus_time/prediction.rb', line 6

def vehicle_id
  @vehicle_id
end

Instance Method Details

#delayed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/bus_time/prediction.rb', line 30

def delayed?
  @delayed
end