Class: RgGen::CodeUtility::Line
- Inherits:
-
Object
- Object
- RgGen::CodeUtility::Line
- Defined in:
- lib/rggen/core_components/code_utility/line.rb
Instance Attribute Summary collapse
-
#indent ⇒ Object
Returns the value of attribute indent.
-
#words ⇒ Object
readonly
Returns the value of attribute words.
Instance Method Summary collapse
- #<<(word) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Line
constructor
A new instance of Line.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Line
Returns a new instance of Line.
4 5 6 7 8 |
# File 'lib/rggen/core_components/code_utility/line.rb', line 4 def initialize @words = [] @not_empty = false @indent = 0 end |
Instance Attribute Details
#indent ⇒ Object
Returns the value of attribute indent.
11 12 13 |
# File 'lib/rggen/core_components/code_utility/line.rb', line 11 def indent @indent end |
#words ⇒ Object (readonly)
Returns the value of attribute words.
10 11 12 |
# File 'lib/rggen/core_components/code_utility/line.rb', line 10 def words @words end |
Instance Method Details
#<<(word) ⇒ Object
13 14 15 16 |
# File 'lib/rggen/core_components/code_utility/line.rb', line 13 def <<(word) @words << word.to_s self end |
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/rggen/core_components/code_utility/line.rb', line 18 def empty? @words.all?(&:empty?) end |
#to_s ⇒ Object
22 23 24 25 |
# File 'lib/rggen/core_components/code_utility/line.rb', line 22 def to_s return '' if @words.empty? @words.join.indent(@indent) end |