Class: ChuckNorrisJokes::Api
- Inherits:
-
Faraday::Connection
- Object
- Faraday::Connection
- ChuckNorrisJokes::Api
- Defined in:
- lib/chuck_norris_jokes/api.rb
Instance Method Summary collapse
- #get_categories ⇒ Object
- #get_random ⇒ Object
- #get_random_in_category(category) ⇒ Object
-
#initialize(url = "https://api.chucknorris.io") ⇒ Api
constructor
A new instance of Api.
- #search(query) ⇒ Object
Constructor Details
#initialize(url = "https://api.chucknorris.io") ⇒ Api
Returns a new instance of Api.
6 7 8 |
# File 'lib/chuck_norris_jokes/api.rb', line 6 def initialize(url="https://api.chucknorris.io") super(url) end |
Instance Method Details
#get_categories ⇒ Object
14 15 16 |
# File 'lib/chuck_norris_jokes/api.rb', line 14 def get_categories self.get "/jokes/categories" end |
#get_random ⇒ Object
10 11 12 |
# File 'lib/chuck_norris_jokes/api.rb', line 10 def get_random self.get "/jokes/random" end |
#get_random_in_category(category) ⇒ Object
18 19 20 |
# File 'lib/chuck_norris_jokes/api.rb', line 18 def get_random_in_category(category) self.get "/jokes/random?category=#{category}" end |
#search(query) ⇒ Object
22 23 24 |
# File 'lib/chuck_norris_jokes/api.rb', line 22 def search(query) self.get "/jokes/search?query=#{query}" end |