Class: VCAP::Logging::Sink::FileSink::MessageBuffer
- Inherits:
-
Object
- Object
- VCAP::Logging::Sink::FileSink::MessageBuffer
- Defined in:
- lib/vcap/logging/sink/file_sink.rb
Instance Attribute Summary collapse
-
#max_buffer_size ⇒ Object
Returns the value of attribute max_buffer_size.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #append(msg) ⇒ Object
- #compact ⇒ Object
- #empty? ⇒ Boolean
- #full? ⇒ Boolean
-
#initialize(buffer_size) ⇒ MessageBuffer
constructor
A new instance of MessageBuffer.
Constructor Details
#initialize(buffer_size) ⇒ MessageBuffer
Returns a new instance of MessageBuffer.
12 13 14 15 16 |
# File 'lib/vcap/logging/sink/file_sink.rb', line 12 def initialize(buffer_size) @max_buffer_size = buffer_size @buffer = [] @size = 0 end |
Instance Attribute Details
#max_buffer_size ⇒ Object
Returns the value of attribute max_buffer_size.
10 11 12 |
# File 'lib/vcap/logging/sink/file_sink.rb', line 10 def max_buffer_size @max_buffer_size end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/vcap/logging/sink/file_sink.rb', line 9 def size @size end |
Instance Method Details
#append(msg) ⇒ Object
18 19 20 21 |
# File 'lib/vcap/logging/sink/file_sink.rb', line 18 def append(msg) @buffer << msg @size += msg.length end |
#compact ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/vcap/logging/sink/file_sink.rb', line 23 def compact return nil unless @size > 0 ret = @buffer.join @buffer = [] @size = 0 ret end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/vcap/logging/sink/file_sink.rb', line 35 def empty? @size == 0 end |
#full? ⇒ Boolean
31 32 33 |
# File 'lib/vcap/logging/sink/file_sink.rb', line 31 def full? @size >= @max_buffer_size end |