Class: StationData
- Inherits:
-
Object
- Object
- StationData
- Defined in:
- lib/station_data.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#duein ⇒ Object
(also: #due_in)
readonly
Returns the value of attribute duein.
-
#expdepart ⇒ Object
readonly
Returns the value of attribute expdepart.
-
#last_location ⇒ Object
readonly
Returns the value of attribute last_location.
-
#late ⇒ Object
readonly
Returns the value of attribute late.
-
#query_time ⇒ Object
readonly
Returns the value of attribute query_time.
-
#servertime ⇒ Object
readonly
Returns the value of attribute servertime.
-
#station_code ⇒ Object
(also: #code)
readonly
Returns the value of attribute station_code.
-
#station_name ⇒ Object
(also: #name)
readonly
Returns the value of attribute station_name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#train_date ⇒ Object
readonly
Returns the value of attribute train_date.
-
#train_type ⇒ Object
readonly
Returns the value of attribute train_type.
-
#traincode ⇒ Object
readonly
Returns the value of attribute traincode.
Instance Method Summary collapse
- #arrival ⇒ Object
- #departure ⇒ Object
- #destination ⇒ Object
-
#initialize(hash) ⇒ StationData
constructor
A new instance of StationData.
- #late? ⇒ Boolean
- #origin ⇒ Object
Constructor Details
#initialize(hash) ⇒ StationData
Returns a new instance of StationData.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/station_data.rb', line 6 def initialize hash @servertime = hash['Servertime'] @traincode = hash['Traincode'] @station_name = hash['Stationfullname'] @station_code = hash['Stationcode'] @query_time = Time.parse(hash['Querytime']) @train_date = hash['Traindate'] @origin = hash['Origin'] @destination = hash['Destination'] @origin_time = Time.parse hash['Origintime'] @destination_time = Time.parse hash['Destinationtime'] @status = hash['Status'] @last_location = hash['Lastlocation'] @duein = hash['Duein'] @late = hash['Late'] @exparrival = Time.parse hash['Exparrival'] @expdepart = Time.parse hash['Expdepart'] @scharrival = Time.parse hash['Scharrival'] @schdepart = Time.parse hash['Schdepart'] @direction = hash['Direction'] @train_type = hash['Traintype'] end |
Instance Attribute Details
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
2 3 4 |
# File 'lib/station_data.rb', line 2 def direction @direction end |
#duein ⇒ Object (readonly) Also known as: due_in
Returns the value of attribute duein.
2 3 4 |
# File 'lib/station_data.rb', line 2 def duein @duein end |
#expdepart ⇒ Object (readonly)
Returns the value of attribute expdepart.
2 3 4 |
# File 'lib/station_data.rb', line 2 def expdepart @expdepart end |
#last_location ⇒ Object (readonly)
Returns the value of attribute last_location.
2 3 4 |
# File 'lib/station_data.rb', line 2 def last_location @last_location end |
#late ⇒ Object (readonly)
Returns the value of attribute late.
2 3 4 |
# File 'lib/station_data.rb', line 2 def late @late end |
#query_time ⇒ Object (readonly)
Returns the value of attribute query_time.
2 3 4 |
# File 'lib/station_data.rb', line 2 def query_time @query_time end |
#servertime ⇒ Object (readonly)
Returns the value of attribute servertime.
2 3 4 |
# File 'lib/station_data.rb', line 2 def servertime @servertime end |
#station_code ⇒ Object (readonly) Also known as: code
Returns the value of attribute station_code.
2 3 4 |
# File 'lib/station_data.rb', line 2 def station_code @station_code end |
#station_name ⇒ Object (readonly) Also known as: name
Returns the value of attribute station_name.
2 3 4 |
# File 'lib/station_data.rb', line 2 def station_name @station_name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
2 3 4 |
# File 'lib/station_data.rb', line 2 def status @status end |
#train_date ⇒ Object (readonly)
Returns the value of attribute train_date.
2 3 4 |
# File 'lib/station_data.rb', line 2 def train_date @train_date end |
#train_type ⇒ Object (readonly)
Returns the value of attribute train_type.
2 3 4 |
# File 'lib/station_data.rb', line 2 def train_type @train_type end |
#traincode ⇒ Object (readonly)
Returns the value of attribute traincode.
2 3 4 |
# File 'lib/station_data.rb', line 2 def traincode @traincode end |
Instance Method Details
#arrival ⇒ Object
37 38 39 |
# File 'lib/station_data.rb', line 37 def arrival {scheduled: @scharrival, expected: @exparrival} end |
#departure ⇒ Object
41 42 43 |
# File 'lib/station_data.rb', line 41 def departure {scheduled: @schdepart, expected: @expdepart} end |
#destination ⇒ Object
33 34 35 |
# File 'lib/station_data.rb', line 33 def destination {name: @destination, time: @destination_time} end |
#late? ⇒ Boolean
45 46 47 |
# File 'lib/station_data.rb', line 45 def late? @late.to_i > 0 end |
#origin ⇒ Object
29 30 31 |
# File 'lib/station_data.rb', line 29 def origin {name: @origin, time: @origin_time} end |