Class: Python::Pickle::Instructions::Global

Inherits:
Python::Pickle::Instruction show all
Defined in:
lib/python/pickle/instructions/global.rb

Instance Attribute Summary collapse

Attributes inherited from Python::Pickle::Instruction

#opcode

Instance Method Summary collapse

Methods inherited from Python::Pickle::Instruction

#inspect

Constructor Details

#initialize(namespace, name) ⇒ Global

Initializes the GLOBAL instruction.

Parameters:

  • namespace (String)

    The namespace name for the global object.

  • name (String)

    The name of the global object.



28
29
30
31
32
33
# File 'lib/python/pickle/instructions/global.rb', line 28

def initialize(namespace,name)
  super(:GLOBAL)

  @namespace = namespace
  @name      = name
end

Instance Attribute Details

#nameString (readonly)

The global object name.

Returns:



17
18
19
# File 'lib/python/pickle/instructions/global.rb', line 17

def name
  @name
end

#namespaceString (readonly)

The global object namespace.

Returns:



12
13
14
# File 'lib/python/pickle/instructions/global.rb', line 12

def namespace
  @namespace
end

Instance Method Details

#==(other) ⇒ Boolean

Compares the GLOBAL instruction to another instruction.

Parameters:

  • other (Instruction)

    The other instruction to compare against.

Returns:

  • (Boolean)

    Indicates whether the other instruction matches this one.



44
45
46
47
48
# File 'lib/python/pickle/instructions/global.rb', line 44

def ==(other)
  super(other) && \
    (@namespace == other.namespace) && \
    (@name == other.name)
end

#to_sString

Converts the GLOBAL instructions to a String.

Returns:



55
56
57
# File 'lib/python/pickle/instructions/global.rb', line 55

def to_s
  "#{super} #{@namespace}.#{@name}"
end