Class: KVVLiveAPI::Departure
- Inherits:
-
Object
- Object
- KVVLiveAPI::Departure
- Defined in:
- lib/kvvliveapi/depature.rb
Overview
Instances of this class represent the depature of a vehicle of a specific route with a specified destination at a specified time.
It contins additional information about the depature and vehicle.
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Final destination of the vehicle.
-
#direction ⇒ Object
readonly
Number representing the direction.
-
#lowfloor ⇒ Object
readonly
Indicates the accessibility of the used vehicle.
-
#realtime ⇒ Object
readonly
Indicates if the depature is a realtime estimation.
-
#route ⇒ Object
readonly
The route for which the depature is valid, e.g.
-
#stop_position ⇒ Object
readonly
Number representing the “sub-stop”, as in some cases a single stops might have different sub-stops for different kinds if vehicles.
-
#time ⇒ Object
readonly
Depature time.
-
#traction ⇒ Object
readonly
Specified if single or double traction is used.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(route, destination, direction, time, lowfloor, realtime, traction, stop_position) ⇒ Departure
constructor
A new instance of Departure.
- #to_s ⇒ Object
Constructor Details
#initialize(route, destination, direction, time, lowfloor, realtime, traction, stop_position) ⇒ Departure
Returns a new instance of Departure.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kvvliveapi/depature.rb', line 48 def initialize(route, destination, direction, time, lowfloor, realtime, traction, stop_position) @route = route @destination = destination @direction = direction @lowfloor = lowfloor @realtime = realtime @traction = traction @time = convert_timestr(time) @stop_position = stop_position end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Final destination of the vehicle
26 27 28 |
# File 'lib/kvvliveapi/depature.rb', line 26 def destination @destination end |
#direction ⇒ Object (readonly)
Number representing the direction
29 30 31 |
# File 'lib/kvvliveapi/depature.rb', line 29 def direction @direction end |
#lowfloor ⇒ Object (readonly)
Indicates the accessibility of the used vehicle
32 33 34 |
# File 'lib/kvvliveapi/depature.rb', line 32 def lowfloor @lowfloor end |
#realtime ⇒ Object (readonly)
Indicates if the depature is a realtime estimation
35 36 37 |
# File 'lib/kvvliveapi/depature.rb', line 35 def realtime @realtime end |
#route ⇒ Object (readonly)
The route for which the depature is valid, e.g. 2 or S7
23 24 25 |
# File 'lib/kvvliveapi/depature.rb', line 23 def route @route end |
#stop_position ⇒ Object (readonly)
Number representing the “sub-stop”, as in some cases a single stops might have different sub-stops for different kinds if vehicles
46 47 48 |
# File 'lib/kvvliveapi/depature.rb', line 46 def stop_position @stop_position end |
#time ⇒ Object (readonly)
Depature time
41 42 43 |
# File 'lib/kvvliveapi/depature.rb', line 41 def time @time end |
#traction ⇒ Object (readonly)
Specified if single or double traction is used
38 39 40 |
# File 'lib/kvvliveapi/depature.rb', line 38 def traction @traction end |
Class Method Details
.from_json(json) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kvvliveapi/depature.rb', line 10 def from_json(json) new(json['route'], json['destination'], json['direction'], json['time'], json['lowfloor'], json['realtime'], json['traction'], json['stopPosition']) end |
Instance Method Details
#to_s ⇒ Object
59 60 61 |
# File 'lib/kvvliveapi/depature.rb', line 59 def to_s @route + ' (-> ' + @destination + ') @ ' + @time.getlocal.strftime('%H:%M') + ', Stop ' + @stop_position.to_s end |