Sha256: 8426617e68d24747078ac1504e338b5e05670ee2f72973dffb44ce3c26f41993
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
class Numeric # convert float values to "cents" # my_value = 2.5 # my_value.to_cents # => 250 def to_cents (self * 100.0).to_i end end class Fixnum #Ęproduce a string of N random letters # 5.random_letters def random_letters generate_random_string_using LETTERS end # produce a string of N random numbers # 5.random_numbers def random_numbers generate_random_string_using NUMBERS end # produce a string of N random characters # 5.random_characters def random_characters generate_random_string_using CHARACTERS end private LETTERS = ('a'..'z').to_a NUMBERS = ('0'..'9').to_a CHARACTERS = LETTERS + NUMBERS def generate_random_string_using legal_characters result = "" upper_limit = legal_characters.size - 1 self.times do | num | result << legal_characters[rand(upper_limit)] end return result end end class String # Return a string that can be used as part of a url def to_url self.downcase.gsub(/[^\-0-9a-z ]/, '').split.join('-') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rahoulb-rujitsu-0.1.0 | lib/rujitsu.rb |