Class: CodeDrivenDevelopment::IndentedOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/code_driven_development/indented_output.rb

Instance Method Summary collapse

Constructor Details

#initializeIndentedOutput

Returns a new instance of IndentedOutput.



3
4
5
6
# File 'lib/code_driven_development/indented_output.rb', line 3

def initialize
  @nesting = 0
  @output = ""
end

Instance Method Details

#<<(str) ⇒ Object



8
9
10
# File 'lib/code_driven_development/indented_output.rb', line 8

def <<(str)
  @output << current_indentation << str << "\n"
end

#indentedObject



12
13
14
15
16
# File 'lib/code_driven_development/indented_output.rb', line 12

def indented
  @nesting += 1
  yield
  @nesting -= 1
end