Sha256: 1a567bc08547c9f58698a69e041e87c8f1612223a1f4887f973d4c08d0fe960a
Contents?: true
Size: 899 Bytes
Versions: 2
Compression:
Stored size: 899 Bytes
Contents
module PyCall module PyObjectWrapper def initialize(pyobj, pytype) check_type pyobj, pytype @__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) && 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.20170224b | lib/pycall/pyobject_wrapper.rb |
pycall-0.1.0.alpha.20170224 | lib/pycall/pyobject_wrapper.rb |