Class: FindT::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/find_t/printer.rb

Instance Method Summary collapse

Constructor Details

#initialize(root_path) ⇒ Printer

Returns a new instance of Printer.



7
8
9
# File 'lib/find_t/printer.rb', line 7

def initialize(root_path)
  @root_path = Pathname.new root_path
end

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/find_t/printer.rb', line 11

def print(name, founds)
  unless founds.any?
    print_empty name
    return
  end

  founds
  .reverse
  .group_by { |f| f[:locale] }
  .sort_by { |f| f[0] }
  .each do |(locale, locale_founds)|
    print_title locale

    locale_founds.each.with_index do |found, i|
      print_translation found, i.zero?
    end
  end
end