Sha256: bf02dc1ffa921a08d6f9d0fca234a03c1f9c84ea3be08c6acbf8d6014560804b
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module PyCall module Utils def callable?(pyobj) case pyobj when PyObject when PyTypeObject pyobj = PyObject.new(pyobj.to_ptr) when PyObjectWrapper pyobj = pyobj.__pyobj__ else raise TypeError, "the argument must be a PyObject" end 1 == LibPython.PyCallable_Check(pyobj) end def dir(pyobj) value = LibPython.PyObject_Dir(pyobj) return value.to_ruby unless value.null? raise PyError.fetch end def int(pyobj) @int ||= PyCall.eval('int') @int.(pyobj) end def len(pyobj) @len ||= PyCall.eval('len') @len.(pyobj) end def slice(*args) Slice.new(*args) end def str(pyobj) @str ||= PyCall.eval('str') @str.(pyobj) end def tuple(*args) PyCall::Tuple[*args] end def type(pyobj) @type ||= PyCall.eval('type') @type.(pyobj) end def format_traceback(pyobj) @format_tb ||= import_module('traceback').format_tb @format_tb.(pyobj) end end extend Utils end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pycall-0.1.0.alpha.20170302 | lib/pycall/utils.rb |