Class: Sec::Connection
- Inherits:
-
Object
- Object
- Sec::Connection
- Defined in:
- lib/sec/connection.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- BASE_URL =
'http://www.sec.gov'
- CONNECT_TIMEOUT =
30
- SUCCESSFUL_RESPONSE =
200
- TIMEOUT =
120
- DEFAULT_SESSION_ATTRIBUTES =
{ :base_url => BASE_URL, :connect_timeout => CONNECT_TIMEOUT, :timeout => TIMEOUT }
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
- #get(uri) ⇒ Object
-
#initialize(attrs = {}) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(attrs = {}) ⇒ Connection
Returns a new instance of Connection.
20 21 22 23 |
# File 'lib/sec/connection.rb', line 20 def initialize(attrs={}) self.session = Patron::Session.new configure_session(attrs) end |
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
12 13 14 |
# File 'lib/sec/connection.rb', line 12 def session @session end |
Instance Method Details
#get(uri) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sec/connection.rb', line 25 def get(uri) response = session.get(uri) response.body if response.respond_to?(:body) rescue Patron::Error => error raise Error, error. end |