Class: RgGen::CodeUtility::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/core_components/code_utility/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLine

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

#indentObject

Returns the value of attribute indent.



11
12
13
# File 'lib/rggen/core_components/code_utility/line.rb', line 11

def indent
  @indent
end

#wordsObject (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

Returns:

  • (Boolean)


18
19
20
# File 'lib/rggen/core_components/code_utility/line.rb', line 18

def empty?
  @words.all?(&:empty?)
end

#to_sObject



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