Class: SpBus::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/spbus/request.rb

Constant Summary collapse

AUTH_URL =
"http://olhovivo.sptrans.com.br/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Request

Returns a new instance of Request.



8
9
10
11
# File 'lib/spbus/request.rb', line 8

def initialize(url)
  @url = url
  @authenticated = true
end

Instance Attribute Details

#authenticated=(value) ⇒ Object (writeonly)

Sets the attribute authenticated

Parameters:

  • value

    the value to set the attribute authenticated to.



6
7
8
# File 'lib/spbus/request.rb', line 6

def authenticated=(value)
  @authenticated = value
end

Instance Method Details

#getObject



13
14
15
16
17
18
19
20
# File 'lib/spbus/request.rb', line 13

def get
  tries ||= 3
  get_cookies if @authenticated
  open(@url, request_headers).read
rescue Errno::ETIMEDOUT => e
  raise e if (tries -= 1) == 0
  retry
end