Sha256: 6eba516946de707de116c00a06cc1c63ff8764617e184cbfe125a1f4ee0f6bcb

Contents?: true

Size: 971 Bytes

Versions: 3

Compression:

Stored size: 971 Bytes

Contents

module Python
  module Pickle
    class Instruction

      # The opcode name.
      #
      # @return [Symbol]
      attr_reader :opcode

      #
      # Initializes the instruction.
      #
      # @param [Symbol] opcode
      #
      def initialize(opcode)
        @opcode = opcode
      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)
        (self.class == other.class) && (@opcode == other.opcode)
      end

      #
      # Converts the instruction into a String.
      #
      # @return [String]
      #
      def to_s
        @opcode.to_s
      end

      #
      # Inspects the instruction.
      #
      # @return [String]
      #
      def inspect
        "#<#{self.class}: #{self}>"
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
python-pickle-0.2.0 lib/python/pickle/instruction.rb
python-pickle-0.1.1 lib/python/pickle/instruction.rb
python-pickle-0.1.0 lib/python/pickle/instruction.rb