Class: Saxlsx::StyleCollectionParser
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- Saxlsx::StyleCollectionParser
- Defined in:
- lib/saxlsx/style_collection_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(&block) ⇒ StyleCollectionParser
constructor
A new instance of StyleCollectionParser.
- #start_element(name) ⇒ Object
Constructor Details
#initialize(&block) ⇒ StyleCollectionParser
Returns a new instance of StyleCollectionParser.
8 9 10 11 12 |
# File 'lib/saxlsx/style_collection_parser.rb', line 8 def initialize(&block) @block = block @cell_styles = false @custom_num_fmts = {} end |
Class Method Details
Instance Method Details
#attr(name, value) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/saxlsx/style_collection_parser.rb', line 44 def attr(name, value) case name when :numFmtId @num_fmt_id = value.to_i when :formatCode @num_fmt_code = value end end |
#end_element(name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/saxlsx/style_collection_parser.rb', line 26 def end_element(name) case name when :cellXfs @cell_styles = false when :xf if @cell_styles custom_num_fmt_code = @custom_num_fmts[@num_fmt_id] if custom_num_fmt_code @block.call custom_num_fmt_code else @block.call @num_fmt_id.to_i end end when :numFmt @custom_num_fmts[@num_fmt_id] = @num_fmt_code end end |
#start_element(name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/saxlsx/style_collection_parser.rb', line 14 def start_element(name) case name when :cellXfs @cell_styles = true when :xf @num_fmt_id = nil when :numFmt @num_fmt_id = nil @num_fmt_code = nil end end |