Class: OoxmlParser::ChartLegend

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ChartLegend.



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

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

Class Method Details

.parse(legend_node) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb', line 20

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

Instance Method Details

#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



15
16
17
18
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb', line 15

def position_with_overlay
  return "#{@position}_overlay".to_sym if overlay
  @position
end