Sha256: e6677075ee9ef69ca6e9ab89458bd8c531b97f7c3ddeca7355d61902cc592b05

Contents?: true

Size: 536 Bytes

Versions: 3

Compression:

Stored size: 536 Bytes

Contents

Array.class_eval do
  alias_method :add, :push

  def sfilter *filters
    filters = filters.first if filters.size == 1 and filters.first.is_a?(Array)
    filters.collect!{|o| o.is_a?(Regexp) ? o : /#{Regexp.escape o}/}
    self.select do |line|
      !filters.any?{|re| line =~ re}
    end
  end

  def self.wrap value
    Array(value)
  end

  alias_method :blank?, :empty?

  alias_method :filter, :select

  def extract_options
    last.is_a?(Hash) ? last : {}
  end

  def extract_options!
    last.is_a?(Hash) ? pop : {}
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_ext-4.0.3 lib/ruby_ext/core/array.rb
ruby_ext-4.0.2 lib/ruby_ext/core/array.rb
ruby_ext-4.0.1 lib/ruby_ext/core/array.rb