Module: Python::Pickle::Instructions::HasValue

Included in:
BinFloat, BinGet, BinInt1, BinPut, Ext1, Ext2, Ext4, Float, Frame, Get, Int, Long, LongBinGet, PersID, Proto, Put, String
Defined in:
lib/python/pickle/instructions/has_value.rb

Overview

A mixin which adds a value to an instruction class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valueObject (readonly)

The value associated with the instruction.

Returns:

  • (Object)


11
12
13
# File 'lib/python/pickle/instructions/has_value.rb', line 11

def value
  @value
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.



35
36
37
# File 'lib/python/pickle/instructions/has_value.rb', line 35

def ==(other)
  super(other) && other.kind_of?(HasValue) && (@value == other.value)
end

#initialize(opcode, value) ⇒ Object

Initializes the instruction.

Parameters:

  • opcode (Symbol)
  • value (Object)


20
21
22
23
24
# File 'lib/python/pickle/instructions/has_value.rb', line 20

def initialize(opcode,value)
  super(opcode)

  @value = value
end

#to_sString

Converts the instruction to a String.

Returns:



44
45
46
# File 'lib/python/pickle/instructions/has_value.rb', line 44

def to_s
  "#{super} #{@value.inspect}"
end