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.
4 5 6 7 8 9 10 11 12 |
# File 'lib/train.rb', line 4 def initialize hash @status = hash['TrainStatus'] @longitude = hash['TrainLongitude'].to_f @latitude = hash['TrainLatitude'].to_f @code = hash['TrainCode'] @date = Date.parse hash['TrainDate'] @message = hash['PublicMessage'] @direction = hash['Direction'] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
2 3 4 |
# File 'lib/train.rb', line 2 def code @code end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
2 3 4 |
# File 'lib/train.rb', line 2 def date @date end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
2 3 4 |
# File 'lib/train.rb', line 2 def direction @direction end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
2 3 4 |
# File 'lib/train.rb', line 2 def @message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
2 3 4 |
# File 'lib/train.rb', line 2 def status @status end |
Instance Method Details
#location ⇒ Object
14 15 16 |
# File 'lib/train.rb', line 14 def location [@longitude,@latitude] end |