Class: RandomYesNo

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

Overview

RandomYesNo class

Constant Summary collapse

URI =
URI('https://yesno.wtf/api')

Class Method Summary collapse

Class Method Details

.showObject

This send a request to yesno.wtf/api to get a random yes/no gif file

Example

Example json repose:
{
  "answer": "yes",
  "forced": false,
  "image": "https://yesno.wtf/assets/yes/2.gif"
}


22
23
24
25
# File 'lib/random_yesno.rb', line 22

def self.show
  res = Net::HTTP.get_response(URI)
  JSON.parse(res.body) if res.is_a?(Net::HTTPSuccess)
end