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.



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']
  @message   = hash['PublicMessage']
  @direction = hash['Direction']
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/train.rb', line 4

def code
  @code
end

#dateObject (readonly)

Returns the value of attribute date.



4
5
6
# File 'lib/train.rb', line 4

def date
  @date
end

#directionObject (readonly)

Returns the value of attribute direction.



4
5
6
# File 'lib/train.rb', line 4

def direction
  @direction
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/train.rb', line 4

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/train.rb', line 4

def status
  @status
end

Instance Method Details

#locationObject



16
17
18
# File 'lib/train.rb', line 16

def location
  [@longitude,@latitude]
end