Class: Treefell::DebugLogger
- Inherits:
-
Object
- Object
- Treefell::DebugLogger
- Defined in:
- lib/treefell/debug_logger.rb
Constant Summary collapse
- DEFAULT_FILTER_PROC =
proc { true }
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(namespace: nil, io: $stdout, color: Color.rotate, filter: nil) ⇒ DebugLogger
constructor
A new instance of DebugLogger.
- #puts(message) ⇒ Object
Constructor Details
#initialize(namespace: nil, io: $stdout, color: Color.rotate, filter: nil) ⇒ DebugLogger
Returns a new instance of DebugLogger.
8 9 10 11 12 13 |
# File 'lib/treefell/debug_logger.rb', line 8 def initialize(namespace: nil, io: $stdout, color: Color.rotate, filter: nil) @namespace = namespace @io = io @color = color @filter = filter || DEFAULT_FILTER_PROC end |
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
6 7 8 |
# File 'lib/treefell/debug_logger.rb', line 6 def filter @filter end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
6 7 8 |
# File 'lib/treefell/debug_logger.rb', line 6 def io @io end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/treefell/debug_logger.rb', line 6 def namespace @namespace end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/treefell/debug_logger.rb', line 27 def ==(other) other.is_a?(self.class) && other.namespace == namespace && other.io == io && other.filter == filter end |
#puts(message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/treefell/debug_logger.rb', line 15 def puts() if @filter.call(namespace, ) formatted_namespace = if namespace @color.colorize(namespace) end @io.puts [ formatted_namespace, ].compact.join(' ') end end |