Module: Numbers
- Extended by:
- Connection
- Defined in:
- lib/numbers.rb,
lib/numbers/connect.rb
Defined Under Namespace
Modules: Connection
Class Method Summary collapse
- .date(day, month) ⇒ Object
- .math(int) ⇒ Object
- .random ⇒ Object
- .trivia(int) ⇒ Object
- .year(int) ⇒ Object
Class Method Details
.date(day, month) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/numbers.rb', line 11 def date(day, month) if day.is_a?(Integer) && month.is_a?(Integer) response = get_response(day, month) JSON.parse(response.body) else puts "day and month must be integers" end end |
.math(int) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/numbers.rb', line 20 def math(int) if int.is_a?(Integer) response = get_response(int) JSON.parse(response.body) else puts "must submit an integer" end end |
.random ⇒ Object
29 30 31 32 33 |
# File 'lib/numbers.rb', line 29 def random types = %w{trivia math date year} response = get_response(types.sample) JSON.parse(response.body) end |
.trivia(int) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/numbers.rb', line 35 def trivia(int) if int.is_a?(Integer) response = get_response(int) JSON.parse(response.body) else puts "must submit an integer" end end |
.year(int) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/numbers.rb', line 44 def year(int) if int.is_a?(Integer) response = get_response(int) JSON.parse(response.body) else puts "must submit an integer" end end |