Class: GuardianSearcher::Base
- Inherits:
-
Object
- Object
- GuardianSearcher::Base
- Includes:
- Faraday
- Defined in:
- lib/guardian_searcher/base.rb
Overview
Class that handles the basic functionality for the Guardian Reader gem
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#initialize(api_key: nil) ⇒ Base
constructor
A new instance of Base.
-
#search(query, options = {}) ⇒ Object
Options needs to be passed following Guardian API docs.
- #search_editions(query, options = {}) ⇒ Object
- #search_sections(query, options = {}) ⇒ Object
- #search_tags(query, options = {}) ⇒ Object
Constructor Details
#initialize(api_key: nil) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 |
# File 'lib/guardian_searcher/base.rb', line 10 def initialize(api_key: nil) raise GuardianApyKeyError unless api_key @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/guardian_searcher/base.rb', line 8 def api_key @api_key end |
Instance Method Details
#search(query, options = {}) ⇒ Object
Options needs to be passed following Guardian API docs
17 18 19 20 |
# File 'lib/guardian_searcher/base.rb', line 17 def search(query, = {}) url = search_uri + query_string(query, ) Faraday.get(url) end |
#search_editions(query, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/guardian_searcher/base.rb', line 32 def search_editions(query, = {}) url = editions_uri + query_string(query, ) Faraday.get(url) end |
#search_sections(query, options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/guardian_searcher/base.rb', line 22 def search_sections(query, = {}) url = sections_uri + query_string(query, ) Faraday.get(url) end |
#search_tags(query, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/guardian_searcher/base.rb', line 27 def (query, = {}) url = + query_string(query, ) Faraday.get(url) end |