Class: Gnews::GnewsRepository
- Inherits:
-
BaseRepository
- Object
- BaseRepository
- Gnews::GnewsRepository
- Defined in:
- lib/metonym/lib/repositories/gnews_repository.rb
Instance Method Summary collapse
-
#initialize(api_key) ⇒ GnewsRepository
constructor
A new instance of GnewsRepository.
- #search(query:) ⇒ Object
- #top_news(query:) ⇒ Object
- #topic ⇒ Object
Methods inherited from BaseRepository
Constructor Details
#initialize(api_key) ⇒ GnewsRepository
Returns a new instance of GnewsRepository.
5 6 7 8 |
# File 'lib/metonym/lib/repositories/gnews_repository.rb', line 5 def initialize(api_key) @gnews_api_key = api_key @uri = 'https://gnews.io/api/v3/' end |
Instance Method Details
#search(query:) ⇒ Object
10 11 12 |
# File 'lib/metonym/lib/repositories/gnews_repository.rb', line 10 def search(query:) request(@uri, query: query, resource: 'search') end |
#top_news(query:) ⇒ Object
14 15 16 |
# File 'lib/metonym/lib/repositories/gnews_repository.rb', line 14 def top_news(query:) request(@uri, query: query, resource: 'top-news') end |
#topic ⇒ Object
18 19 20 |
# File 'lib/metonym/lib/repositories/gnews_repository.rb', line 18 def topic request(@uri, query: query, resource: 'topic') end |