Class: SpBus::Request
- Inherits:
-
Object
- Object
- SpBus::Request
- Defined in:
- lib/spbus/request.rb
Constant Summary collapse
- AUTH_URL =
"http://olhovivo.sptrans.com.br/"
Instance Attribute Summary collapse
-
#authenticated ⇒ Object
writeonly
Sets the attribute authenticated.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(url) ⇒ Request
constructor
A new instance of Request.
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
6 7 8 |
# File 'lib/spbus/request.rb', line 6 def authenticated=(value) @authenticated = value end |
Instance Method Details
#get ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/spbus/request.rb', line 13 def get tries ||= 3 if @authenticated open(@url, request_headers).read rescue Errno::ETIMEDOUT => e raise e if (tries -= 1) == 0 retry end |