Class: AhrefsAPI::Base
- Inherits:
-
Object
- Object
- AhrefsAPI::Base
- Includes:
- HTTParty
- Defined in:
- lib/ahrefs_api/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
Instance Method Summary collapse
-
#get_json(target) ⇒ Object
returns the endpoint data for the target in JSON format.
-
#initialize(api_token = ENV['AHREFS_TOKEN']) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(api_token = ENV['AHREFS_TOKEN']) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 |
# File 'lib/ahrefs_api/base.rb', line 12 def initialize(api_token = ENV['AHREFS_TOKEN']) @mode ||= :domain @token = api_token raise "No token: please provide a valid token for the AhrefsAPI" if @token.nil? end |
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
11 12 13 |
# File 'lib/ahrefs_api/base.rb', line 11 def mode @mode end |
Instance Method Details
#get_json(target) ⇒ Object
returns the endpoint data for the target in JSON format
20 21 22 23 |
# File 'lib/ahrefs_api/base.rb', line 20 def get_json(target) return get_data(target) if target.is_a? Hash get_data(target: target) end |