Class: TodoFind::DefaultFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/todofind/formatters/default_formatter.rb

Overview

Public: The default output formatter to use when printing the search data.

Instance Method Summary collapse

Instance Method Details

#render(data) ⇒ Object

Public: Render the given data.

data - The search data to render. (ex: Data returned from

TodoFind::Finder#find

Returns a String of the rendered data.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/todofind/formatters/default_formatter.rb', line 12

def render(data)
  output = ""
  data.each do |file|
    filename = file[:filename]

    output << "#{filename.green}:\n"

    file[:comments].each do |comment|
      output <<
        "#{comment[:line]}: [#{comment[:label].red}] #{comment[:comment]}\n"
    end
    output << "\n"
  end
  output
end