Class: SJCBusSchedule::Parser::Bus

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

Instance Method Summary collapse

Constructor Details

#initialize(doc:) ⇒ Bus

Returns a new instance of Bus.



7
8
9
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 7

def initialize(doc:)
  @doc = doc
end

Instance Method Details

#directionObject



19
20
21
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 19

def direction
  @direction ||= @doc.css("span[id*=Sentido]").first.text.strip
end

#itineraryObject



23
24
25
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 23

def itinerary
  @itinerary ||= @doc.css("span[id*=Itinerario]").first.text.split(/[-–]/).map(&:strip)
end

#nameObject



15
16
17
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 15

def name
  @name ||= @doc.css("span[id*=NomeLinha]").first.text.strip
end

#noteObject



27
28
29
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 27

def note
  @note ||= @doc.css("span[id*=Observacao]").first.text.strip
end

#numberObject



11
12
13
# File 'lib/sjc_bus_schedule/parser/parser.rb', line 11

def number
  @number ||= @doc.css("span[id*=NumeroLinha]").first.text.strip
end