Module: Jiazi
- Defined in:
- lib/jiazi.rb,
lib/jiazi/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Class Method Summary collapse
- .custom(number = 1, min = 10, max = 20) ⇒ Object
- .fetch(number, min, max) ⇒ Object
- .paragraph ⇒ Object
- .result(json) ⇒ Object
- .title ⇒ Object
Class Method Details
.custom(number = 1, min = 10, max = 20) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/jiazi.rb', line 10 def custom(number = 1, min = 10, max = 20) if max < min "max should be greater or equal to min." else fetch(number, min, max) end end |
.fetch(number, min, max) ⇒ Object
26 27 28 |
# File 'lib/jiazi.rb', line 26 def fetch(number, min, max) result JSON.load(open("http://more.handlino.com/sentences.json?n=#{number}&limit=#{min},#{max}")) end |
.paragraph ⇒ Object
22 23 24 |
# File 'lib/jiazi.rb', line 22 def paragraph custom(1, 400, 500) end |
.result(json) ⇒ Object
30 31 32 |
# File 'lib/jiazi.rb', line 30 def result json json["sentences"] end |
.title ⇒ Object
18 19 20 |
# File 'lib/jiazi.rb', line 18 def title custom(1) end |