Class: Train

Inherits:
Object
  • Object
show all
Defined in:
lib/train.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (readonly)

Returns the value of attribute code.



2
3
4
# File 'lib/train.rb', line 2

def code
  @code
end

#dateObject (readonly)

Returns the value of attribute date.



2
3
4
# File 'lib/train.rb', line 2

def date
  @date
end

#directionObject (readonly)

Returns the value of attribute direction.



2
3
4
# File 'lib/train.rb', line 2

def direction
  @direction
end

#messageObject (readonly)

Returns the value of attribute message.



2
3
4
# File 'lib/train.rb', line 2

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



2
3
4
# File 'lib/train.rb', line 2

def status
  @status
end

Instance Method Details

#locationObject



14
15
16
# File 'lib/train.rb', line 14

def location
  [@longitude,@latitude]
end