Sha256: dea207e2f3f4c2d4a37ff7f35d63e59f4bd1882d50579be361f2a2eac98b7476
Contents?: true
Size: 589 Bytes
Versions: 1
Compression:
Stored size: 589 Bytes
Contents
require 'uri' require 'net/http' require 'urban_dictionary/version' require 'urban_dictionary/word' require 'urban_dictionary/entry' module UrbanDictionary DEFINE_URL = 'http://www.urbandictionary.com/define.php' RANDOM_URL = 'http://www.urbandictionary.com/random.php' def self.define(str) Word.from_url("#{DEFINE_URL}?term=#{URI.encode(str)}") end def self.random_word url = URI.parse(RANDOM_URL) req = Net::HTTP::Get.new(url.path) rsp = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } Word.from_url(rsp['location']) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
urban_dictionary-0.0.1 | lib/urban_dictionary.rb |