Sha256: 05cf16148f9558821b7c2ce0fe70a229c44a63330cad8e56c30b9b71c861a622

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

class Prawn::SVG::Elements::DepthFirstBase < Prawn::SVG::Elements::Base
  def initialize(document, source, parent_calls, state)
    super
    @base_calls = @calls = @parent_calls
  end

  def process
    parse_step
    apply_step(calls)
  rescue SkipElementQuietly
  rescue SkipElementError => e
    @document.warnings << e.message
  end

  def parse_and_apply
    raise "unsupported"
  end

  protected

  def parse_step
    extract_attributes_and_properties
    parse_standard_attributes
    parse
    parse_child_elements if container?
  end

  def apply_step(calls)
    @base_calls = @calls = calls
    apply_calls_from_standard_attributes
    apply
    apply_child_elements if container?
  end

  def parse_child_elements
    return unless source

    source.elements.each do |elem|
      if element_class = Prawn::SVG::Elements::TAG_CLASS_MAPPING[elem.name.to_sym]
        child = element_class.new(@document, elem, @calls, state.dup)
        child.parse_step
        @children << child
      end
    end
  end

  def apply_child_elements
    @children.each do |child|
      child.apply_step(calls)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prawn-svg-0.25.2 lib/prawn/svg/elements/depth_first_base.rb
prawn-svg-0.25.1 lib/prawn/svg/elements/depth_first_base.rb
prawn-svg-0.25.0 lib/prawn/svg/elements/depth_first_base.rb