Class: BufferedLogger::Padding
- Inherits:
-
Object
- Object
- BufferedLogger::Padding
- Defined in:
- lib/buffered_logger/indentation.rb
Constant Summary collapse
- PADDING_CHAR =
' '
- PADDING_RESET =
:reset
Instance Attribute Summary collapse
-
#padding_char ⇒ Object
Returns the value of attribute padding_char.
Instance Method Summary collapse
- #%(message) ⇒ Object
- #indent(indent_level) ⇒ Object
-
#initialize(params = {}) ⇒ Padding
constructor
A new instance of Padding.
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Padding
Returns a new instance of Padding.
31 32 33 34 35 |
# File 'lib/buffered_logger/indentation.rb', line 31 def initialize(params = {}) @padding = '' @padding_char = params[:padding_char] || PADDING_CHAR indent(params[:indent] || 0) end |
Instance Attribute Details
#padding_char ⇒ Object
Returns the value of attribute padding_char.
29 30 31 |
# File 'lib/buffered_logger/indentation.rb', line 29 def padding_char @padding_char end |
Instance Method Details
#%(message) ⇒ Object
57 58 59 |
# File 'lib/buffered_logger/indentation.rb', line 57 def %() @padding + .to_s end |
#indent(indent_level) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/buffered_logger/indentation.rb', line 45 def indent(indent_level) @padding = \ if indent_level == PADDING_RESET '' elsif indent_level > 0 @padding + (@padding_char * indent_level) else @padding[0..(-1+indent_level)] end indent_level end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/buffered_logger/indentation.rb', line 41 def to_s @padding end |