Class: Typ::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(typ) ⇒ Formatter

Returns a new instance of Formatter.



6
7
8
9
10
11
12
13
# File 'lib/typ/formatter.rb', line 6

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



15
16
17
# File 'lib/typ/formatter.rb', line 15

def to_s
  @string
end