Module: Itamae::Logger::Helper
- Defined in:
- lib/itamae/logger.rb
Instance Method Summary collapse
- #color(code, &block) ⇒ Object
- #indent ⇒ Object
- #indent_depth ⇒ Object
- #indent_depth=(val) ⇒ Object
- #outdent ⇒ Object
- #with_indent ⇒ Object
- #with_indent_if(condition, &block) ⇒ Object
Instance Method Details
#color(code, &block) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/itamae/logger.rb', line 40 def color(code, &block) if self.formatter.respond_to?(:color) self.formatter.color(code, &block) else block.call end end |
#indent ⇒ Object
23 24 25 |
# File 'lib/itamae/logger.rb', line 23 def indent self.indent_depth += 1 end |
#indent_depth ⇒ Object
32 33 34 |
# File 'lib/itamae/logger.rb', line 32 def indent_depth @indent_depth ||= 0 end |
#indent_depth=(val) ⇒ Object
36 37 38 |
# File 'lib/itamae/logger.rb', line 36 def indent_depth=(val) @indent_depth = val end |
#outdent ⇒ Object
27 28 29 30 |
# File 'lib/itamae/logger.rb', line 27 def outdent self.indent_depth -= 1 self.indent_depth = 0 if self.indent_depth < 0 end |
#with_indent ⇒ Object
8 9 10 11 12 13 |
# File 'lib/itamae/logger.rb', line 8 def with_indent indent yield ensure outdent end |
#with_indent_if(condition, &block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/itamae/logger.rb', line 15 def with_indent_if(condition, &block) if condition with_indent(&block) else block.call end end |