Module: Python::Pickle::Instructions::HasNamespaceAndName

Included in:
Global, Inst
Defined in:
lib/python/pickle/instructions/has_namespace_and_name.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameString (readonly)

The constant name.

Returns:



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

def name
  @name
end

#namespaceString (readonly)

The constant's namespace.

Returns:



8
9
10
# File 'lib/python/pickle/instructions/has_namespace_and_name.rb', line 8

def namespace
  @namespace
end

Instance Method Details

#==(other) ⇒ Boolean

Compares the instruction to another instruction.

Parameters:

  • other (Instruction)

    The other instruction to compare against.

Returns:

  • (Boolean)

    Indicates whether the other instruction matches this one.



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

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

#initialize(opcode, namespace, name) ⇒ Object

Initializes the instruction.

Parameters:

  • opcode (Symbol)

    The instruction's opcode.

  • namespace (String)

    The namespace name for the constant.

  • name (String)

    The name of the constant.



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

def initialize(opcode,namespace,name)
  super(opcode)

  @namespace = namespace
  @name      = name
end

#to_sString

Converts the instructions to a String.

Returns:



54
55
56
# File 'lib/python/pickle/instructions/has_namespace_and_name.rb', line 54

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