Sha256: 0af33b46184fecf9138ab04a5a2b61fd6b55c1523b9f4a724f8ee93a0ca06199

Contents?: true

Size: 213 Bytes

Versions: 6

Compression:

Stored size: 213 Bytes

Contents

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
forgery-0.3.12 lib/forgery/extensions/range.rb
forgery-0.3.11 lib/forgery/extensions/range.rb
forgery-0.3.10 lib/forgery/extensions/range.rb
forgery-0.3.9 lib/forgery/extensions/range.rb
forgery-0.3.8 lib/forgery/extensions/range.rb
forgery-0.3.7 lib/forgery/extensions/range.rb