Class: OoxmlParser::ChartCellsRange

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

Overview

Cell Range of Chart

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(parent: nil) ⇒ ChartCellsRange

Returns a new instance of ChartCellsRange.



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

def initialize(parent: nil)
  @list = ''
  @points = []
  @parent = parent
end

Instance Attribute Details

#listObject

Returns the value of attribute list.



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

def list
  @list
end

#pointsObject

Returns the value of attribute points.



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

def points
  @points
end

Instance Method Details

#parse(node) ⇒ ChartCellsRange

Parse ChartCellsRange object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



15
16
17
18
19
20
21
22
23
24
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb', line 15

def parse(node)
  @list = node.xpath('c:f')[0].text.split('!').first
  coordinates = Coordinates.parser_coordinates_range(node.xpath('c:f')[0].text) # .split('!')[1].gsub('$', ''))
  node.xpath('c:numCache/c:pt').each_with_index do |point_node, index|
    point = ChartPoint.new(coordinates[index])
    point.value = point_node.xpath('c:v').first.text.to_f unless point_node.xpath('c:v').first.nil?
    @points << point
  end
  self
end