class JpStringsFinder::Printer
Attributes
list[R]
Public Class Methods
new(list)
click to toggle source
# File lib/jp_strings_finder/printer.rb, line 9 def initialize(list) @list = list end
Public Instance Methods
print_table()
click to toggle source
# File lib/jp_strings_finder/printer.rb, line 13 def print_table table = Terminal::Table.new do |t| t.headings = ['File', 'Type', 'Strings'] list.each_with_index do |hash, index| t.add_row( [ to_relative_path(Dir.pwd, hash[:file]), hash[:type].upcase, hash[:strings].join("\n") ] ) t.add_separator unless index == list.count - 1 end end puts table strings_count = list.inject(0) { |acc, elem| acc + elem[:strings].count } STDERR.puts "There are #{strings_count} Japanese strings in #{list.count} files".colorize(:yellow) end
Private Instance Methods
to_relative_path(root, path)
click to toggle source
# File lib/jp_strings_finder/printer.rb, line 34 def to_relative_path(root, path) Pathname.new(path).relative_path_from(Pathname.new(root)).to_s end