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

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(position = :right, overlay = false, parent: nil) ⇒ ChartLegend

Returns a new instance of ChartLegend.



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

def initialize(position = :right,
               overlay = false,
               parent: nil)
  @position = position
  @overlay = overlay
  @parent = parent
end

Instance Attribute Details

#overlayObject

Returns the value of attribute overlay.



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

def overlay
  @overlay
end

#positionObject

Returns the value of attribute position.



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

def position
  @position
end

Instance Method Details

#parse(node) ⇒ ChartLegend

Parse ChartLegend object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb', line 26

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
# 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