Class: Gnews::GnewsRepository

Inherits:
BaseRepository show all
Defined in:
lib/metonym/lib/repositories/gnews_repository.rb

Instance Method Summary collapse

Methods inherited from BaseRepository

#request

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

#topicObject



18
19
20
# File 'lib/metonym/lib/repositories/gnews_repository.rb', line 18

def topic
  request(@uri, query: query, resource: 'topic')
end