Class: Puma::IOBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/java_io_buffer.rb

Constant Summary collapse

BUF_DEFAULT_SIZE =
4096

Instance Method Summary collapse

Constructor Details

#initializeIOBuffer

Returns a new instance of IOBuffer.



14
15
16
# File 'lib/puma/java_io_buffer.rb', line 14

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

Instance Method Details

#<<(str) ⇒ Object



22
23
24
25
# File 'lib/puma/java_io_buffer.rb', line 22

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

#append(*strs) ⇒ Object



27
28
29
# File 'lib/puma/java_io_buffer.rb', line 27

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

#capacityObject



41
42
43
# File 'lib/puma/java_io_buffer.rb', line 41

def capacity
  @buf.buf.length
end

#resetObject



18
19
20
# File 'lib/puma/java_io_buffer.rb', line 18

def reset
  @buf.reset
end

#to_sObject Also known as: to_str



31
32
33
# File 'lib/puma/java_io_buffer.rb', line 31

def to_s
  String.from_java_bytes @buf.to_byte_array
end

#usedObject



37
38
39
# File 'lib/puma/java_io_buffer.rb', line 37

def used
  @buf.size
end