lib/urban_pass/generate.rb in urban_pass-0.1.0 vs lib/urban_pass/generate.rb in urban_pass-0.2.0
- old
+ new
@@ -1,7 +1,8 @@
require 'open-uri'
require 'nokogiri'
+require 'urban'
require 'clipboard'
require 'thread'
module UrbanPass
class Generate
@@ -28,28 +29,31 @@
end
def random_word
page = Nokogiri::HTML(open("http://urbandictionary.com/random.php"))
page.css('a.word')[0].text
- rescue SocketError
+ rescue SocketError
puts "Your not connected to the internet, silly!"
exit
end
def remove_spaces(phrase)
phrase.gsub(" ", "")
end
-
def phrase_length(phrase)
return phrase.length
end
-
def copy(phrase)
word = Clipboard.copy(phrase)
if Clipboard.paste == phrase
return word
end
+ end
+
+ def defination(word)
+ dictionary = Urban::Dictionary.new
+ return dictionary.search(word)
end
end
end