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'], activate_debug = false) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(api_token = ENV['AHREFS_TOKEN'], activate_debug = false) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 16 17 |
# File 'lib/ahrefs_api/base.rb', line 11 def initialize(api_token = ENV['AHREFS_TOKEN'], activate_debug = false) @mode ||= :domain @token = api_token self.class.debug_output $stdout if activate_debug 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.
10 11 12 |
# File 'lib/ahrefs_api/base.rb', line 10 def mode @mode end |
Instance Method Details
#get_json(target) ⇒ Object
returns the endpoint data for the target in JSON format
21 22 23 24 |
# File 'lib/ahrefs_api/base.rb', line 21 def get_json(target) return get_data(target) if target.is_a? Hash get_data(target: target) end |