Sha256: 1ebe6ca78aa08c19f97449c133442f047c14b378f584d15f8fa52a36d53fa2a6

Contents?: true

Size: 900 Bytes

Versions: 7

Compression:

Stored size: 900 Bytes

Contents

begin
  require 'google_hash'
  
  class ::GoogleHashSparseRubyToRuby
    
    alias each_pair each

    # This is mainly used in tests, which is
    # why we allow for a silly implementation.
    #
    def == hash
      return false unless hash.respond_to?(:to_h)
    
      self.each do |key, value|
        return false if hash[key] != value
      end
      hash.each do |key, value|
        return false if self[key] != value
      end
    
      true
    end
  
    # I am a hashy thing.
    #
    def to_hash
      true
    end
  
    # TODO
    #
    def inject init, &block
      result = init
      each do |key, value|
        result = block.call result, [key, value]
      end
      result
    end
  
    # TODO
    #
    def size
      result = 0
      # each only accepts a block
      each { result += 1 }
      result
    end

  end
  
rescue LoadError
  # Welp. Don't do anything.
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
picky-4.31.3 lib/picky/backends/google_hash.rb
picky-4.31.2 lib/picky/backends/google_hash.rb
picky-4.31.1 lib/picky/backends/google_hash.rb
picky-4.31.0 lib/picky/backends/google_hash.rb
picky-4.30.0 lib/picky/backends/google_hash.rb
picky-4.29.0 lib/picky/backends/google_hash.rb
picky-4.28.1 lib/picky/backends/google_hash.rb