Class: Train
- Inherits:
-
Object
- Object
- Train
- Defined in:
- lib/train.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Train
constructor
A new instance of Train.
- #location ⇒ Object
Constructor Details
#initialize(hash) ⇒ Train
Returns a new instance of Train.
6 7 8 9 10 11 12 13 14 |
# File 'lib/train.rb', line 6 def initialize hash @status = hash['TrainStatus'] @longitude = hash['TrainLongitude'].to_f @latitude = hash['TrainLatitude'].to_f @code = hash['TrainCode'] @date = Date.parse hash['TrainDate'] = hash['PublicMessage'] @direction = hash['Direction'] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/train.rb', line 4 def code @code end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
4 5 6 |
# File 'lib/train.rb', line 4 def date @date end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
4 5 6 |
# File 'lib/train.rb', line 4 def direction @direction end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/train.rb', line 4 def end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/train.rb', line 4 def status @status end |
Instance Method Details
#location ⇒ Object
16 17 18 |
# File 'lib/train.rb', line 16 def location [@longitude,@latitude] end |