Class: Sevgi::Graphics::Mixtures::Render::Renderer::Inlines

Inherits:
Object
  • Object
show all
Defined in:
lib/sevgi/graphics/mixtures/render.rb

Defined Under Namespace

Classes: Mark

Instance Method Summary collapse

Constructor Details

#initializeInlines

Returns a new instance of Inlines.



55
# File 'lib/sevgi/graphics/mixtures/render.rb', line 55

def initialize = @marks = []

Instance Method Details

#join(output, indent:, separator:) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/sevgi/graphics/mixtures/render.rb', line 61

def join(output, indent:, separator:)
  return if @marks.empty?

  @marks.each do |mark|
    depth = mark.depth

    ((mark.start + 1)..mark.stop).each do |i|
      output[i].map! { |line| line.delete_prefix(indent * (depth + 1)) }
      output[mark.start][-1] += output[i].join(separator)
      output[i] = nil
    end
  end

  output.compact!
end

#start(index, depth) ⇒ Object



57
# File 'lib/sevgi/graphics/mixtures/render.rb', line 57

def start(index, depth) = @marks << Mark.new(start: index, depth:)

#stop(index) ⇒ Object



59
# File 'lib/sevgi/graphics/mixtures/render.rb', line 59

def stop(index) = @marks.last.stop = index