Class: RgGen::Core::Utility::CodeUtility::Line

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#indentObject

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

Returns:

  • (Boolean)


28
29
30
# File 'lib/rggen/core/utility/code_utility/line.rb', line 28

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

#to_sObject



32
33
34
# File 'lib/rggen/core/utility/code_utility/line.rb', line 32

def to_s
  [' ' * (@indent || 0), *@words].join
end