Class: Typ::Formatter

Inherits:
Object
  • Object
show all
Includes:
FormatGate
Defined in:
lib/typ/formatter.rb

Defined Under Namespace

Modules: FormatGate

Instance Method Summary collapse

Methods included from FormatGate

#format_gate

Constructor Details

#initialize(typ) ⇒ Formatter

Returns a new instance of Formatter.



109
110
111
112
113
114
115
116
# File 'lib/typ/formatter.rb', line 109

def initialize typ
  k = typ.class
  @string = if typ.ok?
              Rainbow(k).green
            else
              Rainbow(k).red + "\n" + format_gates_of(typ).indent(2)
            end
end

Instance Method Details

#to_sObject



118
119
120
# File 'lib/typ/formatter.rb', line 118

def to_s
  @string
end