Class: Forgery::Extensions::Range

Inherits:
Range
  • Object
show all
Defined in:
lib/forgery/extensions/range.rb

Instance Method Summary collapse

Instance Method Details

#randomObject



9
10
11
12
13
14
15
# File 'lib/forgery/extensions/range.rb', line 9

def random
  Integer(first) && Integer(last)
  raise ArgumentError if first > last
  Kernel.rand(last - first + (exclude_end? ? 0 : 1)) + first
rescue ArgumentError
  Forgery::Extend(to_a).random
end

#unextendObject



5
6
7
# File 'lib/forgery/extensions/range.rb', line 5

def unextend
  ::Range.new(first, last, exclude_end?)
end