Class: Oxcelix::Styles

Inherits:
Ox::Sax
  • Object
show all
Defined in:
lib/oxcelix/sax/styles.rb

Overview

Ox based SAX parser which pushes the number formats (taken from the styles.xml file) to an array The reference taken from the cell's 's' attribute points to an element of the style array, which in turn points to a number format (numFmt) that can be either built-in (@formats) or defined in the styles.xml itself.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStyles


10
11
12
13
14
15
# File 'lib/oxcelix/sax/styles.rb', line 10

def initialize
  @temparray = []
  @styleary  = []
  @xmlstack  = []
  @numform   = {}
end

Instance Attribute Details

#stylearyObject

Returns the value of attribute styleary


9
10
11
# File 'lib/oxcelix/sax/styles.rb', line 9

def styleary
  @styleary
end

#temparrayObject

Returns the value of attribute temparray


9
10
11
# File 'lib/oxcelix/sax/styles.rb', line 9

def temparray
  @temparray
end

#xmlstackObject

Returns the value of attribute xmlstack


9
10
11
# File 'lib/oxcelix/sax/styles.rb', line 9

def xmlstack
  @xmlstack
end

Instance Method Details

#attr(name, str) ⇒ Object


45
46
47
# File 'lib/oxcelix/sax/styles.rb', line 45

def attr(name, str)
  self.send name, str if self.respond_to?(name)
end

#end_element(name) ⇒ Object


41
42
43
# File 'lib/oxcelix/sax/styles.rb', line 41

def end_element(name)
  @xmlstack.pop
end

#formatCode(str) ⇒ Object


33
34
35
# File 'lib/oxcelix/sax/styles.rb', line 33

def formatCode str
  nf :formatCode, str
end

#nf(key, value) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/oxcelix/sax/styles.rb', line 17

def nf key, value
  @numform[key]=value
  if @numform.size == 2
    @temparray << @numform
    @numform = {}
  end
end

#numFmtId(str) ⇒ Object


25
26
27
28
29
30
31
# File 'lib/oxcelix/sax/styles.rb', line 25

def numFmtId str
  if @xmlstack[-2] == :cellXfs
    @styleary << str
  elsif @xmlstack[-2] == :numFmts
    nf :numFmtId, str
  end
end

#start_element(name) ⇒ Object


37
38
39
# File 'lib/oxcelix/sax/styles.rb', line 37

def start_element(name)
  @xmlstack << name
end