lib/urban_pass/generate.rb in urban_pass-0.0.3.1 vs lib/urban_pass/generate.rb in urban_pass-0.0.4
- old
+ new
@@ -3,25 +3,32 @@
require 'clipboard'
module UrbanPass
class Generate
- def generate
+ def generate_word
# Generate word:
urban = random_word
# Remove the extra spaces
- word = remove_spaces(urban)
+ remove_spaces(urban)
+ end
- # Return the length of the phrase and print out the word
- puts "Your word is: #{word}"
- puts "The word is #{phrase_length(word)} charcters long"
+ def generate_phrase
+ arr = []
+ 4.times do
+ word = random_word
+ arr << remove_spaces(word)
+ end
+ pass_phrase = arr.join
+ copy(pass_phrase)
+ return pass_phrase
end
def random_word
page = Nokogiri::HTML(open("http://urbandictionary.com/random.php"))
- word = page.css('a.word')[0].text
+ page.css('a.word')[0].text
end
def remove_spaces(phrase)
phrase.gsub(" ", "")
end
@@ -29,24 +36,13 @@
def phrase_length(phrase)
return phrase.length
end
- def generate_phrase
- arr = []
- 4.times do
- word = random_word
- arr << remove_spaces(word)
- end
- pass_phrase = arr.join
- copy(pass_phrase)
- return pass_phrase
- end
def copy(phrase)
word = Clipboard.copy(phrase)
if Clipboard.paste == phrase
- puts "The password was copied correctly!!"
return word
end
end
end
end