Sha256: 0a6702f6f66851ad59a7310fccf2ea87808b133d6dc125ba77f5e8e6d8312b8a

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

module MPatch

  module Extend

    module Random

      def string(length= 7,amount=1,hyphen= " ")
        amount_container= []
        amount.times do
          mrg= ""
          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)
        self.rand(length)
      end

      def boolean
        self.rand(2) == 1
      end

      def time from = Time.at(1114924812), to = Time.now
        self.rand(from..to)
      end

      def date from = Time.at(1114924812), to = Time.now
        self.rand(from..to).to_date
      end

      def datetime from = Time.at(1114924812), to = Time.now
        self.rand(from..to).to_datetime
      end

    end

  end

  require File.join 'mpatch','injector'


end

## alias in Random from RND
#begin
#  (RND.singleton_methods-Object.instance_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

11 entries across 11 versions & 1 rubygems

Version Path
mpatch-2.12.2 lib/mpatch/random.rb
mpatch-2.12.1 lib/mpatch/random.rb
mpatch-2.12.0 lib/mpatch/random.rb
mpatch-2.11.0 lib/mpatch/random.rb
mpatch-2.9.0 lib/mpatch/random.rb
mpatch-2.8.1 lib/mpatch/random.rb
mpatch-2.8.0 lib/mpatch/random.rb
mpatch-2.7.0 lib/mpatch/random.rb
mpatch-2.6.0 lib/mpatch/random.rb
mpatch-2.5.0 lib/mpatch/random.rb
mpatch-2.4.0 lib/mpatch/random.rb