Class: RgGen::Core::Utility::CodeUtility::Line
- Defined in:
- lib/rggen/core/utility/code_utility/line.rb
Instance Attribute Summary collapse
-
#indent ⇒ Object
Returns the value of attribute indent.
Instance Method Summary collapse
- #<<(word) ⇒ Object
- #concat(line) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(indent = 0) ⇒ Line
constructor
A new instance of Line.
- #to_s ⇒ Object
Constructor Details
#initialize(indent = 0) ⇒ Line
Returns a new instance of Line.
8 9 10 11 |
# File 'lib/rggen/core/utility/code_utility/line.rb', line 8 def initialize(indent = 0) @indent = indent @words = [] end |
Instance Attribute Details
#indent ⇒ Object
Returns the value of attribute indent.
13 14 15 |
# File 'lib/rggen/core/utility/code_utility/line.rb', line 13 def indent @indent end |
Instance Method Details
#<<(word) ⇒ Object
19 20 21 22 |
# File 'lib/rggen/core/utility/code_utility/line.rb', line 19 def <<(word) @words << word self end |
#concat(line) ⇒ Object
24 25 26 |
# File 'lib/rggen/core/utility/code_utility/line.rb', line 24 def concat(line) @words.concat(line.words) end |
#empty? ⇒ Boolean
28 29 30 |
# File 'lib/rggen/core/utility/code_utility/line.rb', line 28 def empty? @words.all?(&method(:empty_word?)) end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/rggen/core/utility/code_utility/line.rb', line 32 def to_s [' ' * (@indent || 0), *@words].join end |