Sha256: b9b6e67f660c520b25166a54c9c808d1227f0ffa6b40e1fb1179fe02cbfe673e

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

module Python
  module Pickle
    module Instructions
      module HasNamespaceAndName
        # The constant's namespace.
        #
        # @return [String]
        attr_reader :namespace

        # The constant name.
        #
        # @return [String]
        attr_reader :name

        #
        # Initializes the instruction.
        #
        # @param [Symbol] opcode
        #   The instruction's opcode.
        #
        # @param [String] namespace
        #   The namespace name for the constant.
        #
        # @param [String] name
        #   The name of the constant.
        #
        def initialize(opcode,namespace,name)
          super(opcode)

          @namespace = namespace
          @name      = name
        end

        #
        # Compares the instruction to another instruction.
        #
        # @param [Instruction] other
        #   The other instruction to compare against.
        #
        # @return [Boolean]
        #   Indicates whether the other instruction matches this one.
        #
        def ==(other)
          super(other) && \
            (@namespace == other.namespace) && \
            (@name == other.name)
        end

        #
        # Converts the instructions to a String.
        #
        # @return [String]
        #
        def to_s
          "#{super} #{@namespace}.#{@name}"
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
python-pickle-0.2.0 lib/python/pickle/instructions/has_namespace_and_name.rb