Module: Sevgi::Graphics::Mixtures::Render::Renderer::Attributes::Hybrid Private

Defined in:
lib/sevgi/graphics/mixtures/render.rb

Overview

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

Hybrid attribute renderer.

Instance Method Summary collapse

Instance Method Details

#attributes(element, depth) ⇒ void

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.

This method returns an undefined value.

Renders attributes inline or in block form according to line length.

Parameters:



36
37
38
39
40
41
42
# File 'lib/sevgi/graphics/mixtures/render.rb', line 36

def attributes(element, depth)
  if attributes_as_block?(lines = element.attributes.to_xml_lines, depth)
    attributes_block(element, depth, lines)
  else
    attributes_inline(element, depth, lines)
  end
end

#attributes_as_block?(lines, depth) ⇒ Boolean

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.

Reports whether attributes should be rendered in block form.

Parameters:

  • lines (Array<String>)

    rendered attribute lines

  • depth (Integer)

    element depth

Returns:

  • (Boolean)


48
49
50
# File 'lib/sevgi/graphics/mixtures/render.rb', line 48

def attributes_as_block?(lines, depth)
  linelength(lines, depth) > options[:linelength]
end

#linelength(lines, depth) ⇒ 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.

Returns the effective inline line length.

Parameters:

  • lines (Array<String>)

    rendered attribute lines

  • depth (Integer)

    element depth

Returns:

  • (Integer)


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

def linelength(lines, depth)
  indent(depth).length + lines.sum(&:length)
end