Class: OoxmlParser::NumberFormats
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::NumberFormats
- Defined in:
- lib/ooxml_parser/xlsx_parser/workbook/style_sheet/number_formats.rb
Overview
Parsing ‘numFmts` tag
Instance Attribute Summary collapse
-
#number_formats_array ⇒ Array, NumberFormat
Array of number formats.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#format_by_id(id) ⇒ NumberFormat?
Value of format.
-
#initialize(parent: nil) ⇒ NumberFormats
constructor
A new instance of NumberFormats.
-
#parse(node) ⇒ NumberFormats
Parse NumberFormats data.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ NumberFormats
Returns a new instance of NumberFormats.
10 11 12 13 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/number_formats.rb', line 10 def initialize(parent: nil) @number_formats_array = [] super end |
Instance Attribute Details
#number_formats_array ⇒ Array, NumberFormat
Returns array of number formats.
8 9 10 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/number_formats.rb', line 8 def number_formats_array @number_formats_array end |
Instance Method Details
#format_by_id(id) ⇒ NumberFormat?
Returns value of format.
37 38 39 40 41 42 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/number_formats.rb', line 37 def format_by_id(id) @number_formats_array.each do |cur_format| return cur_format if cur_format.id == id end nil end |
#parse(node) ⇒ NumberFormats
Parse NumberFormats data
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/number_formats.rb', line 18 def parse(node) node.attributes.each do |key, value| case key when 'count' @count = value.value.to_i end end node.xpath('*').each do |node_child| case node_child.name when 'numFmt' @number_formats_array << NumberFormat.new(parent: self).parse(node_child) end end self end |