Module: UrbanDictionary
- Defined in:
- lib/urbandict.rb
Constant Summary collapse
- URL =
'http://api.urbandictionary.com/v0/define'
Class Method Summary collapse
-
.define(word) ⇒ Array<Slang>
Gets the definitions for the word.
Class Method Details
.define(word) ⇒ Array<Slang>
Gets the definitions for the word.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/urbandict.rb', line 13 def define(word) params = { term: word } @client = HTTPClient.new if @client.nil? response = JSON.parse(@client.get(URI.parse(URL), params).body) ret = [] response['list'].each do |hash| ret << Slang.new(hash) end ret end |