Class: PyCall::GCGuard::Key

Inherits:
Struct
  • Object
show all
Defined in:
lib/pycall/gc_guard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pyptr) ⇒ Key

Returns a new instance of Key.



8
9
10
11
# File 'lib/pycall/gc_guard.rb', line 8

def initialize(pyptr)
  self.pyptr = check_pyptr(pyptr)
  # LibPython.Py_IncRef(pyptr)
end

Instance Attribute Details

#pyptrObject

Returns the value of attribute pyptr

Returns:

  • (Object)

    the current value of pyptr



7
8
9
# File 'lib/pycall/gc_guard.rb', line 7

def pyptr
  @pyptr
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



18
19
20
21
22
23
24
25
# File 'lib/pycall/gc_guard.rb', line 18

def ==(other)
  case other
  when Key
    pyptr.pointer == other.pyptr.pointer
  else
    super
  end
end

#hashObject



29
30
31
# File 'lib/pycall/gc_guard.rb', line 29

def hash
  pyptr.pointer.address
end

#releaseObject



13
14
15
16
# File 'lib/pycall/gc_guard.rb', line 13

def release
  # LibPython.Py_DecRef(pyptr)
  self.pyptr = nil
end