module Horesase
Constants
- HORESASE_URL
- VERSION
Public Class Methods
random()
click to toggle source
# File lib/horesase.rb, line 8 def random parse_json.sample end
search(keyword, limit: 10)
click to toggle source
# File lib/horesase.rb, line 12 def search(keyword, limit: 10) results = parse_json.select do |json| json[:title].include?(keyword) || json[:body].include?(keyword) end results.take(limit) end
Private Class Methods
parse_json()
click to toggle source
# File lib/horesase.rb, line 21 def parse_json JSON.parse(open(HORESASE_URL).read, symbolize_names: true) end