module UrbanDictionary
Constants
- URL
Public Instance Methods
define(word)
click to toggle source
Gets the definitions for the word. @param word [String] The word to define. @return [Array<Slang>] An array of #{Slang} objects.
# 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