class LogicTools::Indenter

Small class for indenting

Public Class Methods

new() click to toggle source

Creates a new indenter.

# File lib/logic_tools/traces.rb, line 9
def initialize
    @indent = 0
end

Public Instance Methods

dec(value = 1) click to toggle source

Decreases the indent level by value.

NOTE:

  • the indent level cannot be bellow 0.

  • the value can be negative.

# File lib/logic_tools/traces.rb, line 28
def dec(value = 1)
    @indent -= value.to_i
    @indent = 0 if @indent < 0
end
inc(value = 1) click to toggle source

Increase the indent level by value.

NOTE:

  • the indent level cannot be bellow 0.

  • the value can be negative.

# File lib/logic_tools/traces.rb, line 18
def inc(value = 1)
    @indent += value.to_i
    @indent = 0 if @indent < 0
end
to_s() click to toggle source

Converts to a string (generates the indent.)

# File lib/logic_tools/traces.rb, line 34
def to_s
    return " " * @indent
end