Class: Printer
- Inherits:
-
Object
- Object
- Printer
- Extended by:
- Forwardable
- Defined in:
- lib/require_bench/color_printer.rb,
lib/require_bench/printer.rb
Overview
third party libs You will need to have gem “colorize” installed! NOTE: You will need to require “colorized_string” in your own code,
in order for this alternate Printer class to load
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#colors ⇒ Object
Returns the value of attribute colors.
Instance Method Summary collapse
-
#initialize ⇒ Printer
constructor
A new instance of Printer.
-
#out_consume(seconds, file, type) ⇒ Object
Log statement when a file completed loading.
-
#out_err(error, file, type) ⇒ Object
Log statement when a file raises an error while loading.
-
#out_start(file, type) ⇒ Object
Log statement when a file starts loading.
Constructor Details
#initialize ⇒ Printer
Returns a new instance of Printer.
16 17 18 |
# File 'lib/require_bench/color_printer.rb', line 16 def initialize @colors = ColorizedString.colors.dup.reject { |x| x.match?(/black|white/) } end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
12 13 14 |
# File 'lib/require_bench/color_printer.rb', line 12 def color @color end |
#colors ⇒ Object
Returns the value of attribute colors.
12 13 14 |
# File 'lib/require_bench/color_printer.rb', line 12 def colors @colors end |
Instance Method Details
#out_consume(seconds, file, type) ⇒ Object
Log statement when a file completed loading
10 11 12 |
# File 'lib/require_bench/printer.rb', line 10 def out_consume(seconds, file, type) printf("🚥 [RequireBench-#{type}] ☑️ %10f %s 🚥\n", seconds, file) end |
#out_err(error, file, type) ⇒ Object
Log statement when a file raises an error while loading
15 16 17 18 19 20 |
# File 'lib/require_bench/printer.rb', line 15 def out_err(error, file, type) printf( "🚥 [RequireBench-#{type}] ❌ '#{error.class}: #{error.}' loading %s 🚥\n#{error.backtrace.join("\n")}", file, ) end |
#out_start(file, type) ⇒ Object
Log statement when a file starts loading
5 6 7 |
# File 'lib/require_bench/printer.rb', line 5 def out_start(file, type) printf("🚥 [RequireBench-#{type}] 📖 %s 🚥\n", file) end |