Class: OoxmlParser::Formula

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb

Overview

Class for parsing ‘formulas` <f>

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#referenceCoordinates (readonly)

Returns reference coordinates.

Returns:



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb', line 7

def reference
  @reference
end

#string_indexStringIndex (readonly)

Returns string index.

Returns:



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb', line 9

def string_index
  @string_index
end

#typeString (readonly)

Returns type.

Returns:

  • (String)

    type



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb', line 11

def type
  @type
end

#valueString (readonly)

Returns value.

Returns:

  • (String)

    value



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb', line 13

def value
  @value
end

Instance Method Details

#empty?True, False

Returns check if formula empty.

Returns:

  • (True, False)

    check if formula empty



35
36
37
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb', line 35

def empty?
  !(reference || string_index || type || value)
end

#parse(node) ⇒ Formula

Parse Formula object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell/formula.rb', line 18

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'ref'
      @reference = Coordinates.parser_coordinates_range(value.value.to_s)
    when 'si'
      @string_index = value.value.to_i
    when 't'
      @type = value.value.to_s
    end
  end

  @value = node.text unless node.text.empty?
  self
end