Class: OoxmlParser::DataValidations

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations.rb

Overview

Class for ‘dataValidations` data

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) ⇒ DataValidations

Returns a new instance of DataValidations.



15
16
17
18
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations.rb', line 15

def initialize(parent: nil)
  @data_validations = []
  super
end

Instance Attribute Details

#countInteger (readonly)

Returns count of validations.

Returns:

  • (Integer)

    count of validations



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations.rb', line 9

def count
  @count
end

#data_validationsArray<DataValidation> (readonly)

Returns list of data validations.

Returns:



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations.rb', line 11

def data_validations
  @data_validations
end

#disable_promptsBoolean (readonly)

Returns is prompts disabled.

Returns:

  • (Boolean)

    is prompts disabled



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations.rb', line 13

def disable_prompts
  @disable_prompts
end

Instance Method Details

#[](key) ⇒ SparklineGroup

Returns accessor.

Returns:



21
22
23
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations.rb', line 21

def [](key)
  data_validations[key]
end

#parse(node) ⇒ DataValidations

Parse DataValidations data

Parameters:

  • node (Nokogiri::XML:Element)

    with DataValidations data

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations.rb', line 28

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'count'
      @count = value.value.to_i
    when 'disablePrompts'
      @disable_prompts = attribute_enabled?(value)
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'dataValidation'
      @data_validations << DataValidation.new(parent: self).parse(node_child)
    end
  end
  self
end