Sha256: 1d3c83f80b0aa560ca8d4a3ff559820c7116b11086765c71f065140b163ea5b4

Contents?: true

Size: 1.09 KB

Versions: 40

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Legend of Chart `legend` tag
  class ChartLegend < OOXMLDocumentObject
    attr_accessor :position, :overlay

    def initialize(params = {})
      @position = params.fetch(:position, :right)
      @overlay = params.fetch(:overlay, false)
      super(parent: params[:parent])
    end

    # Return combined data from @position and @overlay
    # If there is no overlay - return :right f.e.
    # If there is overlay - return :right_overlay
    # @return [Symbol] overlay and position type
    def position_with_overlay
      return "#{@position}_overlay".to_sym if overlay

      @position
    end

    # Parse ChartLegend object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [ChartLegend] result of parsing
    def parse(node)
      node.xpath('*').each do |child_node|
        case child_node.name
        when 'legendPos'
          @position = value_to_symbol(child_node.attribute('val'))
        when 'overlay'
          @overlay = true if child_node.attribute('val').value.to_s == '1'
        end
      end
      self
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb