Class: Puma::IOBuffer
- Inherits:
-
Object
- Object
- Puma::IOBuffer
- Defined in:
- lib/puma/java_io_buffer.rb
Constant Summary collapse
- BUF_DEFAULT_SIZE =
4096
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #append(*strs) ⇒ Object
- #capacity ⇒ Object
-
#initialize ⇒ IOBuffer
constructor
A new instance of IOBuffer.
- #reset ⇒ Object
- #to_s ⇒ Object (also: #to_str)
- #used ⇒ Object
Constructor Details
#initialize ⇒ IOBuffer
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 |
#capacity ⇒ Object
41 42 43 |
# File 'lib/puma/java_io_buffer.rb', line 41 def capacity @buf.buf.length end |
#reset ⇒ Object
18 19 20 |
# File 'lib/puma/java_io_buffer.rb', line 18 def reset @buf.reset end |
#to_s ⇒ Object 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 |
#used ⇒ Object
37 38 39 |
# File 'lib/puma/java_io_buffer.rb', line 37 def used @buf.size end |