Class: Range

Inherits:
Object show all
Defined in:
lib/sequel_core/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#intervalObject

Returns the interval between the beginning and end of the range.

For exclusive ranges, is one less than the inclusive range:

(0..10).interval # => 10
(0...10).interval # => 9

Only works for numeric ranges, for other ranges the result is undefined, and the method may raise an error.



159
160
161
# File 'lib/sequel_core/core_ext.rb', line 159

def interval
  last - first - (exclude_end? ? 1 : 0)
end