Class: Cycromatic::TextFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cycromatic/text_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io:) ⇒ TextFormatter

Returns a new instance of TextFormatter.



5
6
7
# File 'lib/cycromatic/text_formatter.rb', line 5

def initialize(io:)
  @io = io
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



3
4
5
# File 'lib/cycromatic/text_formatter.rb', line 3

def io
  @io
end

Instance Method Details

#calculated(path:, complexity:) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cycromatic/text_formatter.rb', line 22

def calculated(path:, complexity:)
  loc = complexity.node.loc
  name = case complexity.type
         when :toplevel
           "[toplevel]"
         when :method
           complexity.node.children.find {|c| c.is_a? Symbol }.to_s
         end

  io.puts "#{path}\t#{name}:#{loc.first_line}\t#{complexity.value}"
end

#completedObject



15
16
# File 'lib/cycromatic/text_formatter.rb', line 15

def completed
end

#error(path:, exception:) ⇒ Object



18
19
20
# File 'lib/cycromatic/text_formatter.rb', line 18

def error(path:, exception:)
  io.puts "#{path}\t(error)"
end

#finished(path:) ⇒ Object



12
13
# File 'lib/cycromatic/text_formatter.rb', line 12

def finished(path:)
end

#started(path:) ⇒ Object



9
10
# File 'lib/cycromatic/text_formatter.rb', line 9

def started(path:)
end