lib/python/pickle/instructions/global.rb in python-pickle-0.1.1 vs lib/python/pickle/instructions/global.rb in python-pickle-0.2.0
- old
+ new
@@ -1,60 +1,30 @@
require 'python/pickle/instruction'
-require 'python/pickle/instructions/has_value'
+require 'python/pickle/instructions/has_namespace_and_name'
module Python
module Pickle
module Instructions
+ #
+ # Represents the `GLOBAL` instruction.
+ #
+ # @note introduced in protocol 0.
+ #
class Global < Instruction
- # The global object namespace.
- #
- # @return [String]
- attr_reader :namespace
+ include HasNamespaceAndName
- # The global object name.
#
- # @return [String]
- attr_reader :name
-
+ # Initializes a `GLOBAL` instruction.
#
- # Initializes the `GLOBAL` instruction.
- #
# @param [String] namespace
- # The namespace name for the global object.
+ # The namespace name for the constant.
#
# @param [String] name
- # The name of the global object.
+ # The name of the constant.
#
def initialize(namespace,name)
- super(:GLOBAL)
-
- @namespace = namespace
- @name = name
- end
-
- #
- # Compares the `GLOBAL` 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 `GLOBAL` instructions to a String.
- #
- # @return [String]
- #
- def to_s
- "#{super} #{@namespace}.#{@name}"
+ super(:GLOBAL,namespace,name)
end
end
end
end