Module: Jisho
- Extended by:
- Jisho
- Included in:
- Jisho
- Defined in:
- lib/jisho.rb,
lib/jisho/util.rb,
lib/jisho/result.rb,
lib/jisho/version.rb
Defined Under Namespace
Modules: Util
Classes: Result
Constant Summary
collapse
- JISHO_API_URL =
"http://jisho.org/api/v1"
- VERSION =
"0.1.0"
Instance Method Summary
collapse
Instance Method Details
#search(words) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/jisho.rb', line 13
def search(words)
path = "/search/words"
uri = URI(JISHO_API_URL)
uri.path << path
uri.query = URI.encode_www_form(keyword: words)
response = Net::HTTP.get_response(uri)
if Net::HTTPSuccess === response
Jisho::Result.display(words, response.body)
else
raise "Could not connect to jisho.org API"
end
end
|