Module: Python::Pickle::Instructions::HasLengthAndValue
- Included in:
- BinBytes, BinBytes8, BinString, BinUnicode, BinUnicode8, ByteArray8, Long1, Long4, ShortBinBytes, ShortBinString, ShortBinUnicode
- Defined in:
- lib/python/pickle/instructions/has_length_and_value.rb
Overview
A mixin which adds a length and a value to an instruction class.
Instance Attribute Summary collapse
-
#length ⇒ Integer
readonly
The length of the value associated with the instruction.
-
#value ⇒ Object
readonly
The value associated with the instruction.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares the instruction to another instruction.
-
#initialize(opcode, length, value) ⇒ Object
Initializes the instruction.
-
#to_s ⇒ String
Converts the instruction to a String.
Instance Attribute Details
#length ⇒ Integer (readonly)
The length of the value associated with the instruction.
11 12 13 |
# File 'lib/python/pickle/instructions/has_length_and_value.rb', line 11 def length @length end |
#value ⇒ Object (readonly)
The value associated with the instruction.
16 17 18 |
# File 'lib/python/pickle/instructions/has_length_and_value.rb', line 16 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
Compares the instruction to another instruction.
41 42 43 44 45 |
# File 'lib/python/pickle/instructions/has_length_and_value.rb', line 41 def ==(other) super(other) && other.kind_of?(HasLengthAndValue) && (@length == other.length && @value == other.value) end |
#initialize(opcode, length, value) ⇒ Object
Initializes the instruction.
25 26 27 28 29 30 |
# File 'lib/python/pickle/instructions/has_length_and_value.rb', line 25 def initialize(opcode,length,value) super(opcode) @value = value @length = length end |
#to_s ⇒ String
Converts the instruction to a String.
52 53 54 |
# File 'lib/python/pickle/instructions/has_length_and_value.rb', line 52 def to_s "#{super} #{@length.inspect} #{@value.inspect}" end |