Class: Saxlsx::RowsCollectionCountParser

Inherits:
Ox::Sax
  • Object
show all
Defined in:
lib/saxlsx/rows_collection_count_parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRowsCollectionCountParser

Returns a new instance of RowsCollectionCountParser.



14
15
16
# File 'lib/saxlsx/rows_collection_count_parser.rb', line 14

def initialize
  @count = 0
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



12
13
14
# File 'lib/saxlsx/rows_collection_count_parser.rb', line 12

def count
  @count
end

Class Method Details

.count(data, &block) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/saxlsx/rows_collection_count_parser.rb', line 4

def self.count(data, &block)
  parser = new
  catch :abort do
    SaxParser.parse parser, data
  end
  parser.count
end

Instance Method Details

#attr(name, value) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/saxlsx/rows_collection_count_parser.rb', line 25

def attr(name, value)
  if @current_element == :dimension
    if name == :ref && value
      matches = value.match(/[^:]+:[A-Z]*(\d+)/)
      if matches
        @count = matches[1].to_i
        throw :abort
      end
    end
  end
end

#start_element(name) ⇒ Object



18
19
20
21
22
23
# File 'lib/saxlsx/rows_collection_count_parser.rb', line 18

def start_element(name)
  @current_element = name
  if name == :row
    @count += 1
  end
end