Class: AmazingPrint::Indentator

Inherits:
Object
  • Object
show all
Defined in:
lib/amazing_print/indentator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indentation) ⇒ Indentator

Returns a new instance of Indentator.



5
6
7
8
# File 'lib/amazing_print/indentator.rb', line 5

def initialize(indentation)
  @indentation = indentation
  @shift_width = indentation.freeze
end

Instance Attribute Details

#indentationObject (readonly)

Returns the value of attribute indentation.



3
4
5
# File 'lib/amazing_print/indentator.rb', line 3

def indentation
  @indentation
end

#shift_widthObject (readonly)

Returns the value of attribute shift_width.



3
4
5
# File 'lib/amazing_print/indentator.rb', line 3

def shift_width
  @shift_width
end

Instance Method Details

#indentObject



10
11
12
13
14
15
# File 'lib/amazing_print/indentator.rb', line 10

def indent
  @indentation += shift_width
  yield
ensure
  @indentation -= shift_width
end