Class: Puma::IOBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/java_io_buffer.rb,
ext/puma_http11/io_buffer.c

Constant Summary collapse

BUF_DEFAULT_SIZE =
4096

Instance Method Summary collapse

Constructor Details

#initializeIOBuffer

Returns a new instance of IOBuffer.



16
17
18
# File 'lib/puma/java_io_buffer.rb', line 16

def initialize
  @buf = JavaIOBuffer.new(BUF_DEFAULT_SIZE)
end

Instance Method Details

#<<(str) ⇒ Object



34
35
36
37
# File 'ext/puma_http11/io_buffer.c', line 34

def <<(str)
  bytes = str.to_java_bytes
  @buf.write(bytes, 0, bytes.length)
end

#append(*args) ⇒ Object



69
70
71
# File 'ext/puma_http11/io_buffer.c', line 69

def append(*strs)
  strs.each { |s| self << s; }
end

#capacityObject



129
130
131
# File 'ext/puma_http11/io_buffer.c', line 129

def capacity
  @buf.buf.length
end

#resetObject



136
137
138
# File 'ext/puma_http11/io_buffer.c', line 136

def reset
  @buf.reset
end

#to_sObject Also known as: to_str



115
116
117
# File 'ext/puma_http11/io_buffer.c', line 115

def to_s
  String.from_java_bytes @buf.to_byte_array
end

#usedObject



122
123
124
# File 'ext/puma_http11/io_buffer.c', line 122

def used
  @buf.size
end