Class: OoxmlParser::ChartLegend

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb

Overview

Legend of Chart ‘legend` tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(params = {}) ⇒ ChartLegend

Returns a new instance of ChartLegend.



8
9
10
11
12
# 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

Instance Attribute Details

#overlayObject

Returns the value of attribute overlay.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb', line 6

def overlay
  @overlay
end

#positionObject

Returns the value of attribute position.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb', line 6

def position
  @position
end

Instance Method Details

#parse(node) ⇒ ChartLegend

Parse ChartLegend object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



27
28
29
30
31
32
33
34
35
36
37
# 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_overlaySymbol

Return combined data from @position and @overlay If there is no overlay - return :right f.e. If there is overlay - return :right_overlay

Returns:

  • (Symbol)

    overlay and position type



18
19
20
21
22
# 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