class OoxmlParser::NumberFormats

Parsing `numFmts` tag

Attributes

number_formats_array[RW]

@return [Array, NumberFormat] array of number formats

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb, line 10
def initialize(parent: nil)
  @number_formats_array = []
  super
end

Public Instance Methods

format_by_id(id) click to toggle source

@param id [Integer] id of format @return [NumberFormat, nil] value of format

# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/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) click to toggle source

Parse NumberFormats data @param [Nokogiri::XML:Element] node with NumberFormats data @return [NumberFormats] value of NumberFormats data

# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/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