Class: Lumberjack::Device::Writer::Buffer
- Inherits:
-
Object
- Object
- Lumberjack::Device::Writer::Buffer
- Defined in:
- lib/lumberjack/device/writer.rb
Overview
Internal buffer to batch writes to the stream.
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #<<(string) ⇒ Object
- #clear ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Buffer
constructor
A new instance of Buffer.
- #join(delimiter) ⇒ Object
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
16 17 18 19 |
# File 'lib/lumberjack/device/writer.rb', line 16 def initialize @values = [] @size = 0 end |
Instance Attribute Details
#size ⇒ Object (readonly)
:nodoc:
14 15 16 |
# File 'lib/lumberjack/device/writer.rb', line 14 def size @size end |
Instance Method Details
#<<(string) ⇒ Object
21 22 23 24 |
# File 'lib/lumberjack/device/writer.rb', line 21 def <<(string) @values << string @size += string.size end |
#clear ⇒ Object
34 35 36 37 |
# File 'lib/lumberjack/device/writer.rb', line 34 def clear @values = [] @size = 0 end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/lumberjack/device/writer.rb', line 26 def empty? @values.empty? end |
#join(delimiter) ⇒ Object
30 31 32 |
# File 'lib/lumberjack/device/writer.rb', line 30 def join(delimiter) @values.join(delimiter) end |