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.
- #pop! ⇒ Object
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
21 22 23 24 |
# File 'lib/lumberjack/device/writer.rb', line 21 def initialize @values = [] @size = 0 end |
Instance Attribute Details
#size ⇒ Object (readonly)
:nodoc:
19 20 21 |
# File 'lib/lumberjack/device/writer.rb', line 19 def size @size end |
Instance Method Details
#<<(string) ⇒ Object
26 27 28 29 |
# File 'lib/lumberjack/device/writer.rb', line 26 def <<(string) @values << string @size += string.size end |
#clear ⇒ Object
42 43 44 45 |
# File 'lib/lumberjack/device/writer.rb', line 42 def clear @values = [] @size = 0 end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/lumberjack/device/writer.rb', line 31 def empty? @values.empty? end |
#pop! ⇒ Object
35 36 37 38 39 40 |
# File 'lib/lumberjack/device/writer.rb', line 35 def pop! return nil if @values.empty? popped = @values clear popped end |