Class: ChuckNorrisJokes::Api

Inherits:
Faraday::Connection
  • Object
show all
Defined in:
lib/chuck_norris_jokes/api.rb

Instance Method Summary collapse

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_categoriesObject



14
15
16
# File 'lib/chuck_norris_jokes/api.rb', line 14

def get_categories
    self.get "/jokes/categories"
end

#get_randomObject



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