Sha256: aa3c4ee2ac6cb7d9820507246eb03cab26d9d544991eebffaf3ce1cbdad4f316

Contents?: true

Size: 964 Bytes

Versions: 27

Compression:

Stored size: 964 Bytes

Contents

class RND
  class << self
    def string(length= 7,amount=1,hyphen= " ")
      amount_container= Array.new
      amount.times do
        mrg= String.new
        mrg= (0...length).map{ ('a'..'z').to_a[rand(26)] }.join
        amount_container.push mrg
      end
      return amount_container.join(hyphen)
    end
    def integer(length= 3)
      Random.rand(length)
    end
    def boolean
      rand(2) == 1
    end
    def time from = Time.at(1114924812), to = Time.now
      rand(from..to)
    end
    def date from = Time.at(1114924812), to = Time.now
      rand(from..to).to_date
    end
    def datetime from = Time.at(1114924812), to = Time.now
      rand(from..to).to_datetime
    end
  end
end

# alias in Random from RND
begin
  (RND.singleton_methods-Object.singleton_methods).each do |one_method_sym|
    Random.class_eval do
      define_singleton_method one_method_sym do |*args|
        RND.__send__(one_method_sym,*args)
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mpatch-1.1.0 lib/mpatch/random.rb
mpatch-1.0.2 lib/mpatch/random.rb
mpatch-1.0.1 lib/mpatch/random.rb
mpatch-1.0.0 lib/mpatch/random.rb
procemon-0.8.1 lib/procemon/mpatch/random.rb
procemon-0.8.0 lib/procemon/mpatch/random.rb
procemon-0.7.0 lib/procemon/mpatch/random.rb
procemon-0.6.3 lib/procemon/mpatch/random.rb
procemon-0.6.2 lib/procemon/mpatch/random.rb
procemon-0.6.1 lib/procemon/mpatch/random.rb
procemon-0.5.0 lib/procemon/mpatch/random.rb
procemon-0.4.5 lib/procemon/mpatch/random.rb
procemon-0.4.4 lib/procemon/mpatch/random.rb
procemon-0.4.3 lib/procemon/mpatch/random.rb
procemon-0.4.2 lib/procemon/mpatch/random.rb
procemon-0.4.1 lib/procemon/mpatch/random.rb
procemon-0.4.0 lib/procemon/mpatch/random.rb
procemon-0.3.4 lib/procemon/mpatch/random.rb
procemon-0.3.3 lib/procemon/mpatch/random.rb
procemon-0.3.2 lib/procemon/mpatch/random.rb