Class: MixinBot::Transaction::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/mixin_bot/transaction/buffer.rb

Overview

Byte cursor for decoding raw transaction bytes.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bytesObject (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

Returns:

  • (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

#sizeObject



25
26
27
# File 'lib/mixin_bot/transaction/buffer.rb', line 25

def size
  @bytes.size
end