Class: Usgs::Client
- Inherits:
-
Object
- Object
- Usgs::Client
- Includes:
- DailyValues, InstantaneousValues, Site, Statistics
- Defined in:
- lib/usgs/client.rb
Instance Attribute Summary collapse
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#api_get(path, query = {}) ⇒ Object
Public: Perform GET and return response from API.
-
#base_url ⇒ Object
Base URL for USGS Water Services.
-
#initialize(timeout: 30, user_agent: "usgs-ruby/#{Usgs::VERSION}", debug: false) ⇒ Client
constructor
A new instance of Client.
Methods included from Statistics
Methods included from Site
Methods included from Utils
#format_date, #format_datetime, #resolve_parameter_codes
Methods included from InstantaneousValues
Methods included from DailyValues
Constructor Details
#initialize(timeout: 30, user_agent: "usgs-ruby/#{Usgs::VERSION}", debug: false) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 |
# File 'lib/usgs/client.rb', line 12 def initialize(timeout: 30, user_agent: "usgs-ruby/#{Usgs::VERSION}", debug: false) @timeout = timeout @user_agent = user_agent @debug = debug end |
Instance Attribute Details
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/usgs/client.rb', line 10 def timeout @timeout end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
10 11 12 |
# File 'lib/usgs/client.rb', line 10 def user_agent @user_agent end |
Instance Method Details
#api_get(path, query = {}) ⇒ Object
Public: Perform GET and return response from API
24 25 26 27 28 29 |
# File 'lib/usgs/client.rb', line 24 def api_get(path, query = {}) query = query.compact url = "#{base_url}#{path}" fetch_url(url, query: query, timeout: timeout, user_agent: user_agent) end |
#base_url ⇒ Object
Base URL for USGS Water Services
19 20 21 |
# File 'lib/usgs/client.rb', line 19 def base_url "https://waterservices.usgs.gov/nwis" end |