Class: StationMaster::Schedule::Departure
- Inherits:
-
Object
- Object
- StationMaster::Schedule::Departure
- Defined in:
- lib/station_master/schedule/departure.rb
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#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) ⇒ Departure
constructor
A new instance of Departure.
- #to_hash ⇒ Object
Constructor Details
#initialize(hash) ⇒ Departure
Returns a new instance of Departure.
6 7 8 9 10 11 12 13 |
# File 'lib/station_master/schedule/departure.rb', line 6 def initialize(hash) @train_code = hash[:numeroTreno] @train_type = hash[:categoria] @destination = hash[:destinazione] @platform = (hash[:binarioProgrammatoPartenzaDescrizione].to_s || '0').strip @time = Time.at((hash[:orarioPartenza] || 0) / 1000).in_time_zone(TIME_ZONE) @delay = hash[:ritardo] end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
4 5 6 |
# File 'lib/station_master/schedule/departure.rb', line 4 def delay @delay end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
4 5 6 |
# File 'lib/station_master/schedule/departure.rb', line 4 def destination @destination end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
4 5 6 |
# File 'lib/station_master/schedule/departure.rb', line 4 def platform @platform end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
4 5 6 |
# File 'lib/station_master/schedule/departure.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/departure.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/departure.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/departure.rb', line 15 def to_hash { train_code: train_code, train_type: train_type, destination: destination, platform: platform, time: time.strftime('%H:%M'), delay: delay } end |