Class: SJCBusSchedule::Parser::Schedules

Inherits:
Object
  • Object
show all
Defined in:
lib/sjc_bus_schedule/parser/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(doc:) ⇒ Schedules

Returns a new instance of Schedules.



33
34
35
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 33

def initialize(doc:)
  @doc = doc
end

Instance Method Details

#referencesObject



43
44
45
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 43

def references
  @references ||= @doc.css("span[id*=Resultado] .textosm").children.map(&:text).reject { |it| it.empty? }
end

#schedulesObject



37
38
39
40
41
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 37

def schedules
  @schedules ||= @doc.css("span[id*=Resultado] > table").map do |schedule|
    { period: period(schedule), hours: hours(schedule) }
  end
end