lib/rujitsu/fixnum.rb in rujitsu-0.3.3 vs lib/rujitsu/fixnum.rb in rujitsu-0.4.0

- old
+ new

@@ -1,5 +1,7 @@ +# encoding: utf-8 + module RujitsuFixnum # produce a string of N random vowels def random_vowels opts={} generate_random_string_using VOWELS, opts end @@ -25,13 +27,13 @@ def random_numbers( opts = {} ) # Then set some defaults, just in case upper = opts[:to] || 9 lower = opts[:from] || 0 only = opts[:only] || :both - + # And finally calculate the number - n = [] + n = [] (self - 1).times do i = (lower..upper).to_a.sort_by { rand }.first n << i.to_s end # add the last digit according to :only @@ -71,18 +73,18 @@ # Run through them all and remove them chars.each do | char | legal_characters.delete(char) end end - + upper_limit = legal_characters.size - 1 srand # seed rand (1..self).collect do |num| legal_characters[rand(upper_limit)] end.join end - + def end_number_choices opt case opt when :even EVENS when :odd