Class: Python::Pickle::PyClass

Inherits:
Object
  • Object
show all
Defined in:
lib/python/pickle/py_class.rb

Overview

Represents a Python class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace = nil, name) ⇒ PyClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the Python class.

Parameters:

  • namespace (String, nil) (defaults to: nil)

    The namespace of the Python class.

  • name (String)

    The name of the Python class.



31
32
33
34
# File 'lib/python/pickle/py_class.rb', line 31

def initialize(namespace=nil,name)
  @namespace = namespace
  @name      = name
end

Instance Attribute Details

#nameString (readonly)

The name of the Python class.

Returns:

  • (String)


18
19
20
# File 'lib/python/pickle/py_class.rb', line 18

def name
  @name
end

#namespaceString (readonly)

The namespace the Python class is defined within.

Returns:

  • (String)


13
14
15
# File 'lib/python/pickle/py_class.rb', line 13

def namespace
  @namespace
end

Instance Method Details

#inspectString

Inspects the Python object.

Returns:

  • (String)


69
70
71
# File 'lib/python/pickle/py_class.rb', line 69

def inspect
  "#<#{self.class}: #{self}>"
end

#new(*args, **kwargs) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a new Python object from the Python class.

Parameters:

  • args (Array)

    Additional __init__ arguments.

  • kwargs (Hash{Symbol => Object})

    Additional __init__ keyword arguments.



47
48
49
# File 'lib/python/pickle/py_class.rb', line 47

def new(*args,**kwargs)
  PyObject.new(self,*args,**kwargs)
end

#to_sString

Converts the Python class into a String.

Returns:

  • (String)


56
57
58
59
60
61
62
# File 'lib/python/pickle/py_class.rb', line 56

def to_s
  if @namespace
    "#{@namespace}.#{@name}"
  else
    @name.to_s
  end
end