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

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ ChartCellsRange

Returns a new instance of ChartCellsRange.



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

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

Instance Attribute Details

#listObject

Returns the value of attribute list.



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

def list
  @list
end

#pointsObject

Returns the value of attribute points.



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

def points
  @points
end

Instance Method Details

#parse(node) ⇒ ChartCellsRange

Parse ChartCellsRange object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb', line 17

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('$', ''))
  return self unless coordinates

  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