Class: AwesomePrint::Indentator
- Defined in:
- lib/awesome_print/indentator.rb
Instance Attribute Summary collapse
-
#indentation ⇒ Object
readonly
Returns the value of attribute indentation.
-
#shift_width ⇒ Object
readonly
Returns the value of attribute shift_width.
Instance Method Summary collapse
- #indent ⇒ Object
-
#initialize(indentation) ⇒ Indentator
constructor
A new instance of Indentator.
Constructor Details
#initialize(indentation) ⇒ Indentator
Returns a new instance of Indentator.
6 7 8 9 |
# File 'lib/awesome_print/indentator.rb', line 6 def initialize(indentation) @indentation = indentation @shift_width = indentation.freeze end |
Instance Attribute Details
#indentation ⇒ Object (readonly)
Returns the value of attribute indentation.
4 5 6 |
# File 'lib/awesome_print/indentator.rb', line 4 def indentation @indentation end |
#shift_width ⇒ Object (readonly)
Returns the value of attribute shift_width.
4 5 6 |
# File 'lib/awesome_print/indentator.rb', line 4 def shift_width @shift_width end |
Instance Method Details
#indent ⇒ Object
11 12 13 14 15 16 |
# File 'lib/awesome_print/indentator.rb', line 11 def indent @indentation += shift_width yield ensure @indentation -= shift_width end |