Class: StationMaster::Schedule::Arrival
- Inherits:
-
Object
- Object
- StationMaster::Schedule::Arrival
- Defined in:
- lib/station_master/schedule/arrival.rb
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#train_code ⇒ Object
readonly
Returns the value of attribute train_code.
-
#train_type ⇒ Object
readonly
Returns the value of attribute train_type.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Arrival
constructor
A new instance of Arrival.
- #to_hash ⇒ Object
Constructor Details
#initialize(hash) ⇒ Arrival
Returns a new instance of Arrival.
6 7 8 9 10 11 12 13 |
# File 'lib/station_master/schedule/arrival.rb', line 6 def initialize(hash) @train_code = hash[:numeroTreno] @train_type = hash[:categoria] @origin = hash[:origine] @platform = (hash[:binarioProgrammatoArrivoDescrizione].to_s || '0').strip @time = Time.at((hash[:orarioArrivo] || 0) / 1000) @delay = hash[:ritardo] end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
4 5 6 |
# File 'lib/station_master/schedule/arrival.rb', line 4 def delay @delay end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
4 5 6 |
# File 'lib/station_master/schedule/arrival.rb', line 4 def origin @origin end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
4 5 6 |
# File 'lib/station_master/schedule/arrival.rb', line 4 def platform @platform end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
4 5 6 |
# File 'lib/station_master/schedule/arrival.rb', line 4 def time @time end |
#train_code ⇒ Object (readonly)
Returns the value of attribute train_code.
4 5 6 |
# File 'lib/station_master/schedule/arrival.rb', line 4 def train_code @train_code end |
#train_type ⇒ Object (readonly)
Returns the value of attribute train_type.
4 5 6 |
# File 'lib/station_master/schedule/arrival.rb', line 4 def train_type @train_type end |
Instance Method Details
#to_hash ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/station_master/schedule/arrival.rb', line 15 def to_hash { train_code: train_code, train_type: train_type, origin: origin, platform: platform, time: time.strftime('%H:%M'), delay: delay } end |