Class: Cycromatic::TextFormatter
- Inherits:
-
Object
- Object
- Cycromatic::TextFormatter
- Defined in:
- lib/cycromatic/text_formatter.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
- #calculated(path:, complexity:) ⇒ Object
- #completed ⇒ Object
- #error(path:, exception:) ⇒ Object
- #finished(path:) ⇒ Object
-
#initialize(io:) ⇒ TextFormatter
constructor
A new instance of TextFormatter.
- #started(path:) ⇒ Object
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
#io ⇒ Object (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 |
#completed ⇒ Object
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 |