Class: Lutra::Formatters::Default

Inherits:
Base
  • Object
show all
Defined in:
lib/lutra/formatters/default.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Lutra::Formatters::Base

Instance Method Details

#display(notes) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/lutra/formatters/default.rb', line 4

def display(notes)
  indent = notes.map(&:line).flatten.max.to_s.size

  notes.group_by { |n| n.file }.each do |file, notes|
    puts "#{format_path(file)}:"
    notes.each do |note|
      puts " * #{prepare(note, indent)}"
    end
    puts
  end
end

#prepare(note, indent) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/lutra/formatters/default.rb', line 16

def prepare(note, indent)
  s =  "[#{note.line.to_s.rjust(indent)}] "
  s << "[#{note.tag}] " if options[:display_tags]
  s << note.text[0..options[:text_size]].strip.chomp
  s << '...' if note.text.size > options[:text_size]
  s
end