Class: JpStringsFinder::Printer
- Inherits:
-
Object
- Object
- JpStringsFinder::Printer
- Defined in:
- lib/jp_strings_finder/printer.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
-
#initialize(list) ⇒ Printer
constructor
A new instance of Printer.
- #print_table ⇒ Object
Constructor Details
#initialize(list) ⇒ Printer
Returns a new instance of Printer.
9 10 11 |
# File 'lib/jp_strings_finder/printer.rb', line 9 def initialize(list) @list = list end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
7 8 9 |
# File 'lib/jp_strings_finder/printer.rb', line 7 def list @list end |
Instance Method Details
#print_table ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |