class Fabricator::Vertical_Peeker::Tangling_Sink

Attributes

longest_line_length[R]
nonblank_line_count[R]

Public Class Methods

new(filename, port) click to toggle source
Calls superclass method
# File lib/mau/fabricator.rb, line 684
def initialize filename, port
  super()
  @filename = filename
  @port = port
  @lineno = 1
  @line = ''
  @indent = 0
  @nonblank_line_count = 0

  @longest_line_length = 0
  return
end

Public Instance Methods

line_count() click to toggle source
# File lib/mau/fabricator.rb, line 747
def line_count
  return @lineno - 1
end
location_ahead() click to toggle source
# File lib/mau/fabricator.rb, line 733
def location_ahead
  return OpenStruct.new(
    filename: @filename,
    line: @lineno,
    column: @line.length + 1)
end
location_behind() click to toggle source
# File lib/mau/fabricator.rb, line 740
def location_behind
  return OpenStruct.new(
    filename: @filename,
    line: @lineno,
    column: @line.length)
end
newline() click to toggle source
# File lib/mau/fabricator.rb, line 702
def newline
  @line.rstrip!
  @port.puts @line
  @lineno += 1
  @nonblank_line_count += 1 unless @line.empty?

  @longest_line_length = @line.length \
      if @line.length > @longest_line_length
  @line = ' ' * @indent
  return
end
pin_indent(level = nil) { || ... } click to toggle source
# File lib/mau/fabricator.rb, line 714
def pin_indent level = nil
  previous_indent = @indent
  begin
    @indent = level || @line.length
    yield
  ensure
    @indent = previous_indent
  end
  return
end
write(s) click to toggle source
# File lib/mau/fabricator.rb, line 697
def write s
  @line << s
  return
end
write_long(s) click to toggle source
# File lib/mau/fabricator.rb, line 725
def write_long s
  s.split(/\n/).each_with_index do |line, i|
    newline unless i.zero?
    write line
  end
  return
end