Sha256: 3013aa1589123f8a39825dab37cf31b3fc62c2819990b43361c2ec9ffc500c2e

Contents?: true

Size: 574 Bytes

Versions: 3

Compression:

Stored size: 574 Bytes

Contents

class RMXWeakToStrongHash < Hash

  def [](key)
    super(RMXWeakHolder.new(key))
  end

  def []=(key, value)
    super(RMXWeakHolder.new(key), value)
  end

  def delete(key)
    super(RMXWeakHolder.new(key))
  end

  def keys
    out = []
    keys = [] + super
    while keys.size > 0
      key = keys.shift
      if val = key.value
        out << val
      end
    end
    out
  end

  def values
    out = []
    keys = [] + self.keys
    while keys.size > 0
      key = keys.shift
      if val = key.value
        out << self[key]
      end
    end
    out
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rmx-0.6.2 lib/motion/RMXWeakToStrongHash.rb
rmx-0.6.1 lib/motion/RMXWeakToStrongHash.rb
rmx-0.6.0 lib/motion/RMXWeakToStrongHash.rb