Class: Bort::Schedule::Leg

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bike_flagObject

Returns the value of attribute bike_flag.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def bike_flag
  @bike_flag
end

#destinationObject

Returns the value of attribute destination.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def destination
  @destination
end

#destination_dateObject

Returns the value of attribute destination_date.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def destination_date
  @destination_date
end

#destination_timeObject

Returns the value of attribute destination_time.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def destination_time
  @destination_time
end

#lineObject

Returns the value of attribute line.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def line
  @line
end

#orderObject

Returns the value of attribute order.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def order
  @order
end

#originObject

Returns the value of attribute origin.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def origin
  @origin
end

#origin_dateObject

Returns the value of attribute origin_date.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def origin_date
  @origin_date
end

#origin_timeObject

Returns the value of attribute origin_time.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def origin_time
  @origin_time
end

#train_head_stationObject

Returns the value of attribute train_head_station.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def train_head_station
  @train_head_station
end

#transfer_codeObject

Returns the value of attribute transfer_code.



81
82
83
# File 'lib/bort/schedule.rb', line 81

def transfer_code
  @transfer_code
end

Class Method Details

.parse(doc) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/bort/schedule.rb', line 85

def self.parse(doc)
  leg                     = Leg.new
  leg.order               = doc.attributes['order'].to_i
  leg.transfer_code       = doc.attributes['transfercode']
  leg.origin              = doc.attributes['origin']
  leg.destination         = doc.attributes['destination']
  leg.origin_date         = Date.parse(doc.attributes['origtimedate'])
  leg.destination_date    = Date.parse(doc.attributes['desttimedate'])
  leg.origin_time         = Time.parse("#{doc.attributes['origtimedate']} #{doc.attributes['origtimemin']}")
  leg.destination_time    = Time.parse("#{doc.attributes['desttimedate']} #{doc.attributes['desttimemin']}")
  leg.line                = doc.attributes['line']
  leg.bike_flag           = doc.attributes['bikeflag'] == '1'
  leg.train_head_station  = doc.attributes['trainheadstation']

  leg
end