Class: EmtApi::Line

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_data = {}) ⇒ Line

Returns a new instance of Line.



8
9
10
11
12
13
14
15
16
# File 'lib/emt_api/line.rb', line 8

def initialize(line_data = {})
  @id           = line_data['line']
  @label        = line_data['label']
  @group_number = line_data['groupNumber'].to_i
  @date_first   = EmtApi::Parser.parse_date line_data['dateFirst']
  @date_end     = EmtApi::Parser.parse_date line_data['dateEnd']
  @origin       = EmtApi::Parser.parse_sentence line_data['nameA']
  @destination  = EmtApi::Parser.parse_sentence line_data['nameB']
end

Instance Attribute Details

#date_endObject

Returns the value of attribute date_end.



6
7
8
# File 'lib/emt_api/line.rb', line 6

def date_end
  @date_end
end

#date_firstObject

Returns the value of attribute date_first.



6
7
8
# File 'lib/emt_api/line.rb', line 6

def date_first
  @date_first
end

#destinationObject

Returns the value of attribute destination.



6
7
8
# File 'lib/emt_api/line.rb', line 6

def destination
  @destination
end

#group_numberObject

Returns the value of attribute group_number.



6
7
8
# File 'lib/emt_api/line.rb', line 6

def group_number
  @group_number
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/emt_api/line.rb', line 6

def id
  @id
end

#labelObject

Returns the value of attribute label.



6
7
8
# File 'lib/emt_api/line.rb', line 6

def label
  @label
end

#originObject

Returns the value of attribute origin.



6
7
8
# File 'lib/emt_api/line.rb', line 6

def origin
  @origin
end

Class Method Details

.allObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/emt_api/line.rb', line 18

def self.all
  response_data = EmtApi::Api.get_list_lines
  lines = []

  unless response_data.nil?
    response_data.each { |line| lines << EmtApi::Line.new(line) }
  end

  lines
end

.find(id) ⇒ Object



29
30
31
32
# File 'lib/emt_api/line.rb', line 29

def self.find(id)
  response_data = EmtApi::Api.get_list_lines(id)
  response_data.nil? ? nil : EmtApi::Line.new(response_data)
end