Sha256: 2543869ddeb4ce8b9574fa5e030020baf05f377e48b5ca4aaa9417dfeb5fffa1

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

require 'open-uri'
require 'nokogiri'

module UrbanPass
  class Generate

    def generate
      # Generate word:
      urban = random_word

      # Remove the extra spaces
      phrase = remove_spaces(urban)

      # Return the length of the phrase and print out the word
      puts "Your new password is: #{phrase}"
      puts "The word is #{phrase_length(phrase)} charcters long"
    end

    def random_word
      page = Nokogiri::HTML(open("http://urbandictionary.com/random.php"))
      word = page.css('a.word')[0].text
    end

    def remove_spaces(phrase)
      phrase.gsub(" ", "")
    end


    def phrase_length(phrase)
      return phrase.length
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
urban_pass-0.0.1.1 lib/urban_pass/generate.rb