Class: Eggshell::Stream::IOWrapper
- Inherits:
-
Object
- Object
- Eggshell::Stream::IOWrapper
- Includes:
- Eggshell::Stream
- Defined in:
- lib/eggshell/stream.rb
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #[](index) ⇒ Object
- #flush ⇒ Object
-
#initialize(stream) ⇒ IOWrapper
constructor
A new instance of IOWrapper.
- #join(str) ⇒ Object
- #write(str) ⇒ Object
Constructor Details
#initialize(stream) ⇒ IOWrapper
Returns a new instance of IOWrapper.
18 19 20 21 |
# File 'lib/eggshell/stream.rb', line 18 def initialize(stream) @stream = stream @buff = [] end |
Instance Method Details
#<<(str) ⇒ Object
23 24 25 |
# File 'lib/eggshell/stream.rb', line 23 def <<(str) @buff << str end |
#[](index) ⇒ Object
35 36 37 |
# File 'lib/eggshell/stream.rb', line 35 def [](index) @buff[index] end |
#flush ⇒ Object
39 40 41 |
# File 'lib/eggshell/stream.rb', line 39 def flush @stream.write(@buff.join("\n")) end |
#join(str) ⇒ Object
31 32 33 |
# File 'lib/eggshell/stream.rb', line 31 def join(str) @buff.join(str) end |
#write(str) ⇒ Object
27 28 29 |
# File 'lib/eggshell/stream.rb', line 27 def write(str) @stream.write(str) end |