Class: MixinBot::Transaction::Buffer
- Inherits:
-
Object
- Object
- MixinBot::Transaction::Buffer
- Defined in:
- lib/mixin_bot/transaction/buffer.rb
Overview
Byte cursor for decoding raw transaction bytes.
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(bytes) ⇒ Buffer
constructor
A new instance of Buffer.
- #peek(byte_count) ⇒ Object
- #shift(byte_count = nil) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(bytes) ⇒ Buffer
Returns a new instance of Buffer.
11 12 13 |
# File 'lib/mixin_bot/transaction/buffer.rb', line 11 def initialize(bytes) @bytes = bytes end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
9 10 11 |
# File 'lib/mixin_bot/transaction/buffer.rb', line 9 def bytes @bytes end |
Instance Method Details
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/mixin_bot/transaction/buffer.rb', line 29 def empty? @bytes.empty? end |
#peek(byte_count) ⇒ Object
21 22 23 |
# File 'lib/mixin_bot/transaction/buffer.rb', line 21 def peek(byte_count) @bytes[0, byte_count] end |
#shift(byte_count = nil) ⇒ Object
15 16 17 18 19 |
# File 'lib/mixin_bot/transaction/buffer.rb', line 15 def shift(byte_count = nil) return @bytes.shift if byte_count.nil? @bytes.shift(byte_count) end |
#size ⇒ Object
25 26 27 |
# File 'lib/mixin_bot/transaction/buffer.rb', line 25 def size @bytes.size end |