Class: Python::Pickle::Protocol
- Inherits:
-
Object
- Object
- Python::Pickle::Protocol
- Defined in:
- lib/python/pickle/protocol.rb
Overview
Common base class for all protocol implementations.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#io ⇒ IO
readonly
The Pickle stream to read or write to.
Instance Method Summary collapse
-
#initialize(io) ⇒ Protocol
constructor
Initializes the protocol.
-
#read {|instruction| ... } ⇒ Array<Instruction>
Reads all instructions from the Pickle stream.
-
#read_instruction ⇒ Instruction
abstract
Reads an instruction from the pickle stream.
Constructor Details
#initialize(io) ⇒ Protocol
Initializes the protocol.
19 20 21 |
# File 'lib/python/pickle/protocol.rb', line 19 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ IO (readonly)
The Pickle stream to read or write to.
11 12 13 |
# File 'lib/python/pickle/protocol.rb', line 11 def io @io end |
Instance Method Details
#read {|instruction| ... } ⇒ Array<Instruction>
Reads all instructions from the Pickle stream.
35 36 37 38 39 40 41 |
# File 'lib/python/pickle/protocol.rb', line 35 def read return enum_for(__method__).to_a unless block_given? until @io.eof? yield read_instruction end end |
#read_instruction ⇒ Instruction
This method is abstract.
Reads an instruction from the pickle stream.
50 51 52 |
# File 'lib/python/pickle/protocol.rb', line 50 def read_instruction raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |