Class: SpBus::Scrapers::Locations
- Inherits:
-
Object
- Object
- SpBus::Scrapers::Locations
- Defined in:
- lib/spbus/scrapers/locations.rb
Constant Summary collapse
- URL =
"http://200.189.189.54/InternetServices/PosicaoLinha"
Instance Attribute Summary collapse
-
#buses ⇒ Object
readonly
Returns the value of attribute buses.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(destination_id) ⇒ Locations
constructor
A new instance of Locations.
Constructor Details
#initialize(destination_id) ⇒ Locations
Returns a new instance of Locations.
8 9 10 |
# File 'lib/spbus/scrapers/locations.rb', line 8 def initialize(destination_id) @destination_id = destination_id end |
Instance Attribute Details
#buses ⇒ Object (readonly)
Returns the value of attribute buses.
6 7 8 |
# File 'lib/spbus/scrapers/locations.rb', line 6 def buses @buses end |
Instance Method Details
#fetch ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/spbus/scrapers/locations.rb', line 12 def fetch doc = SpBus::Request.new(url_with_params).get @json = JSON.parse(doc, symbolize_names: true)[:PosicaoLinhaResult] validate_response @buses = @json[:vs].collect do |hash| build_bus(hash) end true end |