Class: Bort::Schedule::SpecialSchedule

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#day_of_weekObject

Returns the value of attribute day_of_week.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def day_of_week
  @day_of_week
end

#destinationObject

Returns the value of attribute destination.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def destination
  @destination
end

#end_dateObject

Returns the value of attribute end_date.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def end_date
  @end_date
end

#end_timeObject

Returns the value of attribute end_time.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def end_time
  @end_time
end

Returns the value of attribute link.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def link
  @link
end

#originObject

Returns the value of attribute origin.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def origin
  @origin
end

#routes_affectedObject

Returns the value of attribute routes_affected.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def routes_affected
  @routes_affected
end

#start_dateObject

Returns the value of attribute start_date.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def start_date
  @start_date
end

#start_timeObject

Returns the value of attribute start_time.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def start_time
  @start_time
end

#textObject

Returns the value of attribute text.



270
271
272
# File 'lib/bort/schedule.rb', line 270

def text
  @text
end

Class Method Details

.parse(doc) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/bort/schedule.rb', line 273

def self.parse(doc)
  schedule                  = SpecialSchedule.new
  schedule.start_date       = Date.parse((doc/:start_date).inner_text)
  schedule.end_date         = Date.parse((doc/:end_date).inner_text)
  schedule.start_time       = Time.parse("#{schedule.start_date.to_s} #{(doc/:start_time).inner_text}")
  schedule.end_time         = Time.parse("#{schedule.end_date.to_s} #{(doc/:end_time).inner_text}")
  schedule.text             = (doc/:text).inner_text
  schedule.link             = (doc/:link).inner_text
  schedule.origin           = (doc/:orig).inner_text
  schedule.destination      = (doc/:dest).inner_text
  schedule.day_of_week      = (doc/:day_of_week).inner_text.split(',').map(&:to_i)
  schedule.routes_affected  = (doc/:routes_affected).inner_text.split(',')

  schedule
end