Class: CatGenerator::Fact

Inherits:
Object
  • Object
show all
Defined in:
lib/cat_generator/fact.rb

Constant Summary collapse

CAT_FACTS_API =
'http://catfacts-api.appspot.com/api/facts'

Class Method Summary collapse

Class Method Details

.nextObject



7
8
9
10
11
12
13
14
# File 'lib/cat_generator/fact.rb', line 7

def self.next
  response = Excon.get(CAT_FACTS_API)

  if response.status == 200
    json_response = JSON.parse(response.body)
    json_response["facts"].first
  end
end