Sha256: 4006c6501831830c0c377ab90d778c8f28afd24b0af86637012fc65b8adeaebd

Contents?: true

Size: 696 Bytes

Versions: 19

Compression:

Stored size: 696 Bytes

Contents

# frozen_string_literal: true

module ActiveObject
  module Range

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

    def include_with_range?(other)
      return include?(other) unless other.is_a?(Range)

      operator = exclude_end? && !other.exclude_end? ? :< : :<=
      include?(other.first) && other.last.send(operator, last)
    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
end

Range.include(ActiveObject::Range) if ActiveObject.configuration.autoload_range

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
active_object-5.14.1 lib/active_object/range.rb
active_object-5.14.0 lib/active_object/range.rb
active_object-5.13.0 lib/active_object/range.rb
active_object-5.12.0 lib/active_object/range.rb
active_object-5.11.0 lib/active_object/range.rb
active_object-5.10.0 lib/active_object/range.rb
active_object-5.9.0 lib/active_object/range.rb
active_object-5.8.11 lib/active_object/range.rb
active_object-5.8.10 lib/active_object/range.rb
active_object-5.8.9 lib/active_object/range.rb
active_object-5.8.8 lib/active_object/range.rb
active_object-5.8.7 lib/active_object/range.rb
active_object-5.8.6 lib/active_object/range.rb
active_object-5.8.5 lib/active_object/range.rb
active_object-5.8.4 lib/active_object/range.rb
active_object-5.8.3 lib/active_object/range.rb
active_object-5.8.2 lib/active_object/range.rb
active_object-5.8.1 lib/active_object/range.rb
active_object-5.8.0 lib/active_object/range.rb