Class: Fixnum

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/monkeypatches.rb

Overview

Enchancement of Fixnum class to generate random number in the interval [0, Fixnum).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(val = 1024) ⇒ Object

Generates random Fixnum in the given interval. We need Fixnum implementing new method for instantiating it as parameter in common way.

Examples:

To create the positive number not greater than 1000:

num = Fixnum.new 1000   # ⇒ 48


86
87
88
# File 'lib/dsl/monkeypatches.rb', line 86

def self.new val = 1024
  val.
end

Instance Method Details

#Object Also known as: any

Generates random Fixnum in the given interval.

Examples:

To create the positive number not greater than 1000:

num = 1000.   # ⇒ 634

Returns:

  • a random number in the given interval.



77
78
79
# File 'lib/dsl/monkeypatches.rb', line 77

def 
  rand(self)
end