module PyBind::Operator
Constants
- BINARY_OPERATION_OPFUNCS
- UNARY_OPERATION_OPFUNCS
Public Instance Methods
!()
click to toggle source
# File lib/pybind/wrapper/operator.rb, line 76 def ! value = LibPython.PyObject_Not(@pystruct) raise PyError.fetch if value == -1 value == 1 end
**(other)
click to toggle source
# File lib/pybind/wrapper/operator.rb, line 53 def **(other) other = other.to_python value = LibPython.PyNumber_Power(@pystruct, other, PyBind.None) raise PyError.fetch if value.null? value.to_ruby end
<=>(other)
click to toggle source
# File lib/pybind/wrapper/operator.rb, line 60 def <=>(other) if LibPython.respond_to? :PyObject_Compare other = other.to_python value = LibPython.PyObject_Compare(@pystruct, other) raise PyError.fetch unless LibPython.PyErr_Occurred().null? value else (self > other) - (self < other) end end
===(other)
click to toggle source
# File lib/pybind/wrapper/operator.rb, line 71 def ===(other) other = other.to_python @pystruct.to_ptr == other.to_ptr end
__binary_operate__(other, op)
click to toggle source
# File lib/pybind/wrapper/operator.rb, line 22 def __binary_operate__(other, op) opfunc = BINARY_OPERATION_OPFUNCS[op] raise ArgumentError, "Unknown binary operation op: #{op}" unless opfunc other = other.to_python value = LibPython.send(opfunc, @pystruct, other) raise PyError.fetch if value.null? value.to_ruby end
__unary_operate__(op)
click to toggle source
# File lib/pybind/wrapper/operator.rb, line 38 def __unary_operate__(op) opfunc = UNARY_OPERATION_OPFUNCS[op] raise ArgumentError, "Unknown unary operation op: #{op}" unless opfunc value = LibPython.send(opfunc, @pystruct) raise PyError.fetch if value.null? value.to_ruby end