class TextExtractor::Directives::Group

a line group

Public Class Methods

new(type, *args) click to toggle source
# File lib/text_extractor/directives/group.rb, line 5
def initialize(type, *args)
  @type = type
  @lines = args
end

Public Instance Methods

<<(item) click to toggle source
# File lib/text_extractor/directives/group.rb, line 10
def <<(item)
  @lines << item
end
chomp(newline) click to toggle source
# File lib/text_extractor/directives/group.rb, line 18
def chomp(newline)
  return if @lines.empty? || newline

  tail = @lines[-1]
  if tail.is_a?(Array)
    tail = tail[-1] while tail[-1].is_a?(Array)
    tail[-2] = tail[-2].chomp
  else
    @lines[-1] = @lines[-1].chomp
  end
end
finish(newline) click to toggle source
# File lib/text_extractor/directives/group.rb, line 30
def finish(newline)
  chomp(newline)
  join
end
join() click to toggle source
# File lib/text_extractor/directives/group.rb, line 35
def join
  ["(#{@type}", *@lines, ')']
end
to_a() click to toggle source
# File lib/text_extractor/directives/group.rb, line 14
def to_a
  @lines
end