Sha256: 8d6a4093452062a29ca5dc0f5b52b0c86edc08b0fb49c17f1c1fd4fc42dc836b

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

module ActiveObject::Range

  def combine(other)
    to_a.concat(other.to_a)
  end

  def include_with_range?(other)
    if other.is_a?(::Range)
      operator = exclude_end? && !other.exclude_end? ? :< : :<=
      include?(other.first) && other.last.send(operator, last)
    else
      include?(other)
    end
  end

  def overlaps?(other)
    cover?(other.first) || other.cover?(first)
  end

  def sample
    to_a.sample
  end

  def shuffle
    to_a.shuffle
  end

  def within?(other)
    cover?(other.first) && cover?(other.last)
  end

end

Range.send(:include, ActiveObject::Range) if ActiveObject::Settings.config.autoload_range

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_object-4.0.0 lib/active_object/range.rb