class PyCall::Dict

Public Class Methods

new(h) click to toggle source
Calls superclass method
# File lib/pycall/dict.rb, line 8
def self.new(h)
  super(h, {})
end

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/pycall/dict.rb, line 24
def [](key)
  super
rescue PyError
  nil
end
delete(key) click to toggle source
# File lib/pycall/dict.rb, line 30
def delete(key)
  v = self[key]
  LibPython::Helpers.delitem(__pyptr__, key)
  v
end
each(&block) click to toggle source
# File lib/pycall/dict.rb, line 36
def each(&block)
  return enum_for unless block_given?
  LibPython::Helpers.dict_each(__pyptr__, &block)
  self
end
has_key?(key) click to toggle source
# File lib/pycall/dict.rb, line 16
def has_key?(key)
  LibPython::Helpers.dict_contains(__pyptr__, key)
end
Also aliased as: include?, key?, member?
include?(key)
Alias for: has_key?
key?(key)
Alias for: has_key?
length() click to toggle source
# File lib/pycall/dict.rb, line 12
def length
  PyCall.len(self)
end
member?(key)
Alias for: has_key?
to_h() click to toggle source
# File lib/pycall/dict.rb, line 42
def to_h
  inject({}) do |h, (k, v)|
    h.update(k => v)
  end
end