Class: RandomYesNo
- Inherits:
-
Object
- Object
- RandomYesNo
- Defined in:
- lib/random_yesno.rb
Overview
RandomYesNo class
Constant Summary collapse
- URI =
URI('https://yesno.wtf/api')
Class Method Summary collapse
-
.show ⇒ Object
This send a request to yesno.wtf/api to get a random yes/no gif file.
Class Method Details
.show ⇒ Object
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 |