Class: Train

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(system_event) ⇒ Train

Returns a new instance of Train.



6
7
8
9
10
11
12
# File 'lib/common/train.rb', line 6

def initialize(system_event)
  @id = system_event[]
  @direction = system_event[]
  @line = system_event[]
  @destination = system_event[]
  @last_updated = system_event[]
end

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



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

def destination
  @destination
end

#directionObject

Returns the value of attribute direction.



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

def direction
  @direction
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#last_updatedObject

Returns the value of attribute last_updated.



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

def last_updated
  @last_updated
end

#lineObject

Returns the value of attribute line.



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

def line
  @line
end

Instance Method Details

#as_json(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/common/train.rb', line 14

def as_json(options={})
  {
    id: @id,
    direction: @direction,
    line: @line,
    destination: @destination,
    last_updated: @last_updated
  }
end

#to_json(*options) ⇒ Object



24
25
26
# File 'lib/common/train.rb', line 24

def to_json(*options)
  as_json(*options).to_json(*options)
end