Class: CodeDrivenDevelopment::IndentedOutput
- Inherits:
-
Object
- Object
- CodeDrivenDevelopment::IndentedOutput
- Defined in:
- lib/code_driven_development/indented_output.rb
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #indented ⇒ Object
-
#initialize ⇒ IndentedOutput
constructor
A new instance of IndentedOutput.
Constructor Details
#initialize ⇒ IndentedOutput
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 |
#indented ⇒ Object
12 13 14 15 16 |
# File 'lib/code_driven_development/indented_output.rb', line 12 def indented @nesting += 1 yield @nesting -= 1 end |