Class: Randr::Generator
- Inherits:
-
Object
- Object
- Randr::Generator
- Defined in:
- lib/randr.rb
Instance Method Summary collapse
- #from(num) ⇒ Object
-
#initialize ⇒ Generator
constructor
A new instance of Generator.
- #times(num) ⇒ Object
- #to(num) ⇒ Object
Constructor Details
#initialize ⇒ Generator
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 |