Module: Jiazi

Defined in:
lib/jiazi.rb,
lib/jiazi/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

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

.paragraphObject



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

.titleObject



18
19
20
# File 'lib/jiazi.rb', line 18

def title
  custom(1)
end