Class: Hashira::Report::FindingLines

Inherits:
Object
  • Object
show all
Defined in:
lib/hashira/report/finding_lines.rb

Constant Summary collapse

SAMPLE =
4

Instance Method Summary collapse

Constructor Details

#initialize(finding, indent: "", io: $stdout) ⇒ FindingLines

Returns a new instance of FindingLines.



8
9
10
11
12
# File 'lib/hashira/report/finding_lines.rb', line 8

def initialize(finding, indent: "", io: $stdout)
  @finding = finding
  @indent = indent
  @io = io
end

Instance Method Details



14
15
16
17
# File 'lib/hashira/report/finding_lines.rb', line 14

def print
  @io.puts "#{@indent}#{@finding.kind}: #{@finding.message}"
  @finding.evidence.first(SAMPLE).each { @io.puts "#{@indent}    · #{_1}" }
end


19
20
21
22
23
# File 'lib/hashira/report/finding_lines.rb', line 19

def print_with_overflow
  print
  overflow = @finding.evidence.size - SAMPLE
  @io.puts "#{@indent}    · … (#{overflow} more)" if overflow.positive?
end