module PyBind::RichComparer

Constants

Py_EQ
Py_GE
Py_GT
Py_LE
Py_LT
Py_NE
RICH_COMPARISON_OPCODES

Public Instance Methods

__rich_compare__(other, op) click to toggle source
# File lib/pybind/wrapper/rich_comparer.rb, line 19
def __rich_compare__(other, op)
  opcode = RICH_COMPARISON_OPCODES[op]
  raise ArgumentError, "Unknown comparison op: #{op}" unless opcode

  other = other.to_python
  return other.null? if @pystruct.null?
  return false if other.null?

  value = LibPython.PyObject_RichCompare(@pystruct, other, opcode)
  raise PyError.fetch if value.null?
  value.to_ruby
end