Class: PQCrypto::Seal::Binary::Reader
- Inherits:
-
Object
- Object
- PQCrypto::Seal::Binary::Reader
- Defined in:
- lib/pq_crypto/seal/binary.rb
Instance Attribute Summary collapse
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
- #bytes(length) ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(bytes, offset = 0) ⇒ Reader
constructor
A new instance of Reader.
Constructor Details
#initialize(bytes, offset = 0) ⇒ Reader
Returns a new instance of Reader.
16 17 18 19 |
# File 'lib/pq_crypto/seal/binary.rb', line 16 def initialize(bytes, offset = 0) @bytes = String(bytes).b @offset = Integer(offset) end |
Instance Attribute Details
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
14 15 16 |
# File 'lib/pq_crypto/seal/binary.rb', line 14 def offset @offset end |
Instance Method Details
#bytes(length) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/pq_crypto/seal/binary.rb', line 25 def bytes(length) length = Integer(length) Binary.ensure_available!(@bytes, offset, length) value = @bytes.byteslice(offset, length).b @offset += length value end |
#finished? ⇒ Boolean
33 34 35 |
# File 'lib/pq_crypto/seal/binary.rb', line 33 def finished? offset == @bytes.bytesize end |