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

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Inline-content output splice helper.

Defined Under Namespace

Classes: Mark

Instance Method Summary collapse

Constructor Details

#initializevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates an inline splice tracker.



99
100
101
102
# File 'lib/sevgi/graphics/mixtures/render.rb', line 99

def initialize
  @marks = []
  @stack = []
end

Instance Method Details

#join(output, indent:, separator:) ⇒ Array<Array<String>, nil>?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Joins marked output ranges into inline content.

Parameters:

  • output (Array<Array<String>, nil>)

    renderer output buffer

  • indent (String)

    indentation unit

  • separator (String)

    line separator

Returns:

  • (Array<Array<String>, nil>, nil)

Raises:

  • (Sevgi::PanicError)

    when an inline range was not closed



132
133
134
135
136
137
138
# File 'lib/sevgi/graphics/mixtures/render.rb', line 132

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

  @marks.reverse_each { |mark| join_mark(output, mark, indent:, separator:) }

  output.compact!
end

#start(index, depth) ⇒ Sevgi::Graphics::Mixtures::Render::Renderer::Inlines::Mark

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Starts an inline splice range.

Parameters:

  • index (Integer)

    output index

  • depth (Integer)

    element depth

Returns:



108
109
110
111
112
113
# File 'lib/sevgi/graphics/mixtures/render.rb', line 108

def start(index, depth)
  Mark.new(start: index, depth:).tap do |mark|
    @marks << mark
    @stack << mark
  end
end

#stop(index) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ends the innermost inline splice range.

Parameters:

  • index (Integer)

    output index

Returns:

  • (Integer)

Raises:

  • (Sevgi::PanicError)

    when no inline range is open



119
120
121
122
123
124
# File 'lib/sevgi/graphics/mixtures/render.rb', line 119

def stop(index)
  mark = @stack.pop
  PanicError.("Inline content range was not opened") unless mark

  mark.stop = index
end