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

#==, 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(title = ChartAxisTitle.new, display = true, major_grid_lines = false, minor_grid_lines = false, parent: nil) ⇒ ChartAxis

Returns a new instance of ChartAxis.



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

def initialize(title = ChartAxisTitle.new,
               display = true,
               major_grid_lines = false,
               minor_grid_lines = false,
               parent: nil)
  @title = title
  @display = display
  @minor_grid_lines = minor_grid_lines
  @major_grid_lines = major_grid_lines
  @parent = parent
end

Instance Attribute Details

#displayObject

Returns the value of attribute display.



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

def display
  @display
end

#major_grid_linesObject

Returns the value of attribute major_grid_lines.



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

def major_grid_lines
  @major_grid_lines
end

#minor_grid_linesObject

Returns the value of attribute minor_grid_lines.



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

def minor_grid_lines
  @minor_grid_lines
end

#positionObject

Returns the value of attribute position.



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

def position
  @position
end

#scalingScaling (readonly)

Returns scaling attribute.

Returns:



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

def scaling
  @scaling
end

#tick_label_positionValuedChild (readonly)

Returns the position of the tick labels.

Returns:



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

def tick_label_position
  @tick_label_position
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#parse(node) ⇒ ChartAxis

Parse ChartAxis object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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

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 if @title.nil?
  self
end