Class: RubyVolt::ReadPartial

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_volt/read_partial.rb

Instance Method Summary collapse

Constructor Details

#initialize(bytes) ⇒ ReadPartial

Returns a new instance of ReadPartial.



3
4
5
# File 'lib/ruby_volt/read_partial.rb', line 3

def initialize(bytes)
  @bytes = bytes
end

Instance Method Details

#inspectObject



7
8
9
# File 'lib/ruby_volt/read_partial.rb', line 7

def inspect
  "<#{self.class.name}: bytes=#{@bytes.bytesize}>"
end

#nreadObject



11
12
13
# File 'lib/ruby_volt/read_partial.rb', line 11

def nread
  @bytes.bytesize
end

#read(num) ⇒ Object Also known as: recv



15
16
17
18
19
# File 'lib/ruby_volt/read_partial.rb', line 15

def read(num)
  exp = @bytes.byteslice(0, num)
  @bytes.delete_prefix!(exp)
  exp
end