Class: Fourflusher::Executable::Indenter
- Inherits:
-
Array
- Object
- Array
- Fourflusher::Executable::Indenter
- Defined in:
- lib/fourflusher/executable.rb
Overview
Helper class that allows to write to an IO instance taking into account the UI indentation level.
Instance Attribute Summary collapse
-
#indent ⇒ Fixnum
The indentation level of the UI.
-
#io ⇒ IO
The IO to which the output should be printed.
Instance Method Summary collapse
-
#<<(value) ⇒ void
Stores a portion of the output and prints it to the IO instance.
-
#initialize(io = nil) ⇒ Indenter
constructor
Init a new Indenter.
Constructor Details
#initialize(io = nil) ⇒ Indenter
Init a new Indenter
218 219 220 221 |
# File 'lib/fourflusher/executable.rb', line 218 def initialize(io = nil) @io = io @indent = ' ' * UI.indentation_level end |
Instance Attribute Details
#indent ⇒ Fixnum
Returns The indentation level of the UI.
208 209 210 |
# File 'lib/fourflusher/executable.rb', line 208 def indent @indent end |
#io ⇒ IO
Returns the IO to which the output should be printed.
212 213 214 |
# File 'lib/fourflusher/executable.rb', line 212 def io @io end |
Instance Method Details
#<<(value) ⇒ void
This method returns an undefined value.
Stores a portion of the output and prints it to the IO instance.
230 231 232 233 |
# File 'lib/fourflusher/executable.rb', line 230 def <<(value) super io << "#{indent}#{value}" if io end |