class OoxmlParser::ChartLegend

Legend of Chart ‘legend` tag

Attributes

overlay[RW]
position[RW]

Public Class Methods

new(params = {}) click to toggle source
Calls superclass method
# File lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb, line 8
def initialize(params = {})
  @position = params.fetch(:position, :right)
  @overlay = params.fetch(:overlay, false)
  super(parent: params[:parent])
end

Public Instance Methods

parse(node) click to toggle source

Parse ChartLegend object @param node [Nokogiri::XML:Element] node to parse @return [ChartLegend] result of parsing

# File lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb, line 27
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
position_with_overlay() click to toggle source

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

# File lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb, line 18
def position_with_overlay
  return "#{@position}_overlay".to_sym if overlay

  @position
end