Sha256: 6e96861675a96a1f4330f7ee834ddc0e3f69f88f70db3b8ef7ab71d35f8164d3

Contents?: true

Size: 655 Bytes

Versions: 17

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

if Lite::Ruby.configuration.monkey_patches.include?('range')
  class 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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
lite-ruby-1.0.31 lib/lite/ruby/range.rb
lite-ruby-1.0.30 lib/lite/ruby/range.rb
lite-ruby-1.0.29 lib/lite/ruby/range.rb
lite-ruby-1.0.28 lib/lite/ruby/range.rb
lite-ruby-1.0.27 lib/lite/ruby/range.rb
lite-ruby-1.0.26 lib/lite/ruby/range.rb
lite-ruby-1.0.25 lib/lite/ruby/range.rb
lite-ruby-1.0.24 lib/lite/ruby/range.rb
lite-ruby-1.0.23 lib/lite/ruby/range.rb
lite-ruby-1.0.22 lib/lite/ruby/range.rb
lite-ruby-1.0.21 lib/lite/ruby/range.rb
lite-ruby-1.0.20 lib/lite/ruby/range.rb
lite-ruby-1.0.19 lib/lite/ruby/range.rb
lite-ruby-1.0.18 lib/lite/ruby/range.rb
lite-ruby-1.0.17 lib/lite/ruby/range.rb
lite-ruby-1.0.16 lib/lite/ruby/range.rb
lite-ruby-1.0.15 lib/lite/ruby/range.rb