Sha256: 5850c57a85c34e2773d41d1ba94c657eedf282a29f4ee9be441df2b186cd6c1d

Contents?: true

Size: 631 Bytes

Versions: 14

Compression:

Stored size: 631 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.include(ActiveObject::Range) if ActiveObject::Settings.config.autoload_range

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
active_object-4.0.14 lib/active_object/range.rb
active_object-4.0.13 lib/active_object/range.rb
active_object-4.0.12 lib/active_object/range.rb
active_object-4.0.11 lib/active_object/range.rb
active_object-4.0.10 lib/active_object/range.rb
active_object-4.0.9 lib/active_object/range.rb
active_object-4.0.8 lib/active_object/range.rb
active_object-4.0.7 lib/active_object/range.rb
active_object-4.0.6 lib/active_object/range.rb
active_object-4.0.5 lib/active_object/range.rb
active_object-4.0.4 lib/active_object/range.rb
active_object-4.0.3 lib/active_object/range.rb
active_object-4.0.2 lib/active_object/range.rb
active_object-4.0.1 lib/active_object/range.rb