Sha256: c3597cf1ea9a8c00a3028e97c61942d0711f094cacdb8e7f16f3bac9c53fc214
Contents?: true
Size: 979 Bytes
Versions: 2
Compression:
Stored size: 979 Bytes
Contents
module PyCall module PyObjectWrapper def initialize(pyobj, pytype=nil) check_type pyobj, pytype pytype ||= LibPython.PyObject_Type(pyobj) @__pyobj__ = pyobj end attr_reader :__pyobj__ def ==(other) case other when self.class __pyobj__ == other.__pyobj__ when PyObject __pyobj__ == other else super end end def call(*args, **kwargs) __pyobj__.call(*args, **kwargs) end def method_missing(name, *args, **kwargs) if PyCall.hasattr?(__pyobj__, name.to_s) PyCall.getattr(__pyobj__, name) else super end end def to_s __pyobj__.to_s end def inspect __pyobj__.inspect end private def check_type(pyobj, pytype) return if pyobj.kind_of?(PyObject) return if pytype.nil? || pyobj.kind_of?(pytype) raise TypeError, "the argument must be a PyObject of #{pytype}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pycall-0.1.0.alpha.20170302 | lib/pycall/pyobject_wrapper.rb |
pycall-0.1.0.alpha.20170226 | lib/pycall/pyobject_wrapper.rb |