class RgGen::Core::Utility::CodeUtility::Line

Attributes

indent[R]
words[R]

Public Class Methods

new(indent = 0) click to toggle source
# File lib/rggen/core/utility/code_utility/line.rb, line 8
def initialize(indent = 0)
  @indent = indent
  @words = []
end

Public Instance Methods

<<(word) click to toggle source
# File lib/rggen/core/utility/code_utility/line.rb, line 19
def <<(word)
  @words << word
  self
end
concat(line) click to toggle source
# File lib/rggen/core/utility/code_utility/line.rb, line 24
def concat(line)
  @words.concat(line.words)
end
empty?() click to toggle source
# File lib/rggen/core/utility/code_utility/line.rb, line 28
def empty?
  @words.all?(&method(:empty_word?))
end
indent=(indent) click to toggle source
# File lib/rggen/core/utility/code_utility/line.rb, line 15
def indent=(indent)
  empty? && (@indent = indent)
end
to_s() click to toggle source
# File lib/rggen/core/utility/code_utility/line.rb, line 32
def to_s
  [' ' * (@indent || 0), *@words].join
end

Private Instance Methods

empty_word?(word) click to toggle source
# File lib/rggen/core/utility/code_utility/line.rb, line 38
def empty_word?(word)
  return true if word.nil?
  return false unless word.respond_to?(:empty?)
  word.empty?
end