Class: Printer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializePrinter

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

#colorObject

Returns the value of attribute color.



12
13
14
# File 'lib/require_bench/color_printer.rb', line 12

def color
  @color
end

#colorsObject

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.message}' 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