Class: OoxmlParser::ChartAxis

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

Overview

Parsing Chart axis tags ‘catAx’, ‘valAx’

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 = {}) ⇒ ChartAxis

Returns a new instance of ChartAxis.



14
15
16
17
18
19
20
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 14

def initialize(params = {})
  @title = params.fetch(:title, ChartAxisTitle.new)
  @display = params.fetch(:display, true)
  @minor_grid_lines = params.fetch(:minor_grid_lines, false)
  @major_grid_lines = params.fetch(:major_grid_lines, false)
  super(parent: params[:parent])
end

Instance Attribute Details

#displayObject

Returns the value of attribute display.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 8

def display
  @display
end

#major_grid_linesObject

Returns the value of attribute major_grid_lines.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 8

def major_grid_lines
  @major_grid_lines
end

#minor_grid_linesObject

Returns the value of attribute minor_grid_lines.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 8

def minor_grid_lines
  @minor_grid_lines
end

#positionObject

Returns the value of attribute position.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 8

def position
  @position
end

#scalingScaling (readonly)

Returns scaling attribute.

Returns:



10
11
12
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 10

def scaling
  @scaling
end

#tick_label_positionValuedChild (readonly)

Returns the position of the tick labels.

Returns:



12
13
14
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 12

def tick_label_position
  @tick_label_position
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 8

def title
  @title
end

Instance Method Details

#parse(node) ⇒ ChartAxis

Parse ChartAxis object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb', line 25

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'delete'
      @display = false if node_child.attribute('val').value == '1'
    when 'title'
      @title = ChartAxisTitle.new(parent: self).parse(node_child)
    when 'majorGridlines'
      @major_grid_lines = true
    when 'minorGridlines'
      @minor_grid_lines = true
    when 'scaling'
      @scaling = Scaling.new(parent: self).parse(node_child)
    when 'tickLblPos'
      @tick_label_position = ValuedChild.new(:symbol, parent: self).parse(node_child)
    when 'axPos'
      @position = value_to_symbol(node_child.attribute('val'))
    end
  end
  @display = false unless @title.visible?
  self
end