Class: ContactData::Fetcher
- Inherits:
-
Object
- Object
- ContactData::Fetcher
- Defined in:
- lib/contact-data/fetcher.rb
Constant Summary collapse
- URL =
ENV['XENDATA_URL'] || 'http://public.xenapto.com'
- API =
'api/v2'
- LOGLEVEL =
Logger::WARN
Instance Attribute Summary collapse
-
#api_method ⇒ Object
readonly
Returns the value of attribute api_method.
-
#http_method ⇒ Object
readonly
Returns the value of attribute http_method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
Instance Attribute Details
#api_method ⇒ Object (readonly)
Returns the value of attribute api_method.
10 11 12 |
# File 'lib/contact-data/fetcher.rb', line 10 def api_method @api_method end |
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
10 11 12 |
# File 'lib/contact-data/fetcher.rb', line 10 def http_method @http_method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/contact-data/fetcher.rb', line 10 def @options end |
Instance Method Details
#parsed_json ⇒ Object
25 26 27 28 |
# File 'lib/contact-data/fetcher.rb', line 25 def parsed_json logger.debug { "Parsing #{json.length} characters of JSON" } JSON.parse(json, symbolize_names: true, allow_nan: true) end |
#url ⇒ Object
30 31 32 33 34 35 |
# File 'lib/contact-data/fetcher.rb', line 30 def url return @url if @url @url = api_method.is_a?(String) ? "#{url_base}/#{api_method}" : "#{api_base}/#{method_base}#{api_method}" @url = "#{@url}.#{[:format] || :json}" unless [:noformat] @url end |