Class: ActionController::CodeGeneration::Source
- Defined in:
- lib/action_controller/code_generation.rb
Overview
:nodoc:
Constant Summary collapse
- IndentationString =
' '
Instance Attribute Summary collapse
-
#indentation_level ⇒ Object
readonly
Returns the value of attribute indentation_level.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
- #indent ⇒ Object
-
#initialize ⇒ Source
constructor
A new instance of Source.
- #line(line) ⇒ Object (also: #<<)
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Source
Returns a new instance of Source.
9 10 11 |
# File 'lib/action_controller/code_generation.rb', line 9 def initialize @lines, @indentation_level = [], 0 end |
Instance Attribute Details
#indentation_level ⇒ Object (readonly)
Returns the value of attribute indentation_level.
7 8 9 |
# File 'lib/action_controller/code_generation.rb', line 7 def indentation_level @indentation_level end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
7 8 9 |
# File 'lib/action_controller/code_generation.rb', line 7 def lines @lines end |
Instance Method Details
#indent ⇒ Object
17 18 19 20 21 22 |
# File 'lib/action_controller/code_generation.rb', line 17 def indent @indentation_level += 1 yield ensure @indentation_level -= 1 end |
#line(line) ⇒ Object Also known as: <<
12 13 14 |
# File 'lib/action_controller/code_generation.rb', line 12 def line(line) @lines << (IndentationString * @indentation_level + line) end |
#to_s ⇒ Object
24 |
# File 'lib/action_controller/code_generation.rb', line 24 def to_s() lines.join("\n") end |