Class: HMap::Executable::Indenter

Inherits:
Array
  • Object
show all
Defined in:
lib/hmap/helper/executable.rb

Overview

Helper class that allows to write to an IO instance taking into account the UI indentation level.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = nil) ⇒ Indenter

Init a new Indenter

Parameters:

  • io (IO) (defaults to: nil)

    @see io



211
212
213
214
# File 'lib/hmap/helper/executable.rb', line 211

def initialize(io = nil)
  @io = io
  @indent = ' ' * 1
end

Instance Attribute Details

#indentFixnum (readonly)

Returns The indentation level of the UI.

Returns:

  • (Fixnum)

    The indentation level of the UI.



201
202
203
# File 'lib/hmap/helper/executable.rb', line 201

def indent
  @indent
end

#ioIO (readonly)

Returns the IO to which the output should be printed.

Returns:

  • (IO)

    the IO to which the output should be printed.



205
206
207
# File 'lib/hmap/helper/executable.rb', line 205

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.

Parameters:

  • value (String)

    the output to print.



223
224
225
226
# File 'lib/hmap/helper/executable.rb', line 223

def <<(value)
  super
  io << "#{indent}#{value}" if io
end