Sha256: 187b43042e781decefe08fe840782803f65778c805ad1bad5fb4107db5ddd8c1

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

# Legend of Chart
module OoxmlParser
  class ChartLegend
    attr_accessor :position, :overlay

    def initialize(position = :right, overlay = false)
      @position = position
      @overlay = overlay
    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

    def self.parse(legend_node)
      legend = ChartLegend.new
      legend_node.xpath('*').each do |legend_node_child|
        case legend_node_child.name
        when 'legendPos'
          legend.position = Alignment.parse(legend_node_child.attribute('val'))
        when 'overlay'
          legend.overlay = true if legend_node_child.attribute('val').value.to_s == '1'
        end
      end
      legend
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ooxml_parser-0.1.2 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb
ooxml_parser-0.1.1 lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb