Sha256: cbd071522de3d78c60e8fb83cfe7985099001f6ae4ef7c6d1d93902cd425e723

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 Bytes

Contents

unless { a: 1 }.respond_to?(:fetch_values)
  # Add fetch_values if this version of ruby does not define it.
  class Hash
    def fetch_values(*keys)
      result = []
      keys.each do |k|
        result <<
          if block_given?
            yield(self[k])
          else
            self[k]
          end
      end
      result
    end
  end
end

unless ''.respond_to?(:match?)
  # Add String#match? to pre-2.4 ruby
  class String
    def match?(re)
      self =~ re
    end
  end
end

unless //.respond_to?(:match?)
  # Add Regexp#match? to pre-2.4 ruby
  class Regexp
    def match?(str)
      self =~ str
    end
  end
end

unless ''.respond_to?(:strip_heredoc)
  class String
    def strip_heredoc
      indent = chomp.scan(/^\s*/).min.size
      gsub(/^\s{#{indent}}/, '')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fat_table-0.2.8 lib/fat_table/patches.rb
fat_table-0.2.7 lib/fat_table/patches.rb