Class: Randr::Generator

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

Instance Method Summary collapse

Constructor Details

#initializeGenerator

Returns a new instance of Generator.



7
8
9
10
# File 'lib/randr.rb', line 7

def initialize
  @times = 1
  @from = 0
end

Instance Method Details

#from(num) ⇒ Object



17
18
19
20
# File 'lib/randr.rb', line 17

def from(num)
  @from = num
  return self
end

#times(num) ⇒ Object



12
13
14
15
# File 'lib/randr.rb', line 12

def times(num)
  @times = num
  return self
end

#to(num) ⇒ Object



22
23
24
25
26
27
# File 'lib/randr.rb', line 22

def to(num)
  @to = num
  return @times.times.map do
    @from + Random.rand(@to - @from + 1)
  end
end