Class: EndiciaLabelServer::Parsers::ParserBase
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- EndiciaLabelServer::Parsers::ParserBase
show all
- Defined in:
- lib/endicia_label_server/parsers/parser_base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ParserBase.
12
13
14
15
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 12
def initialize
self.switches = {}
self.current_attributes = {}
end
|
Instance Attribute Details
#current_attributes ⇒ Object
Returns the value of attribute current_attributes.
7
8
9
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 7
def current_attributes
@current_attributes
end
|
#error_description ⇒ Object
Returns the value of attribute error_description.
7
8
9
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 7
def error_description
@error_description
end
|
#status_code ⇒ Object
Returns the value of attribute status_code.
7
8
9
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 7
def status_code
@status_code
end
|
#switches ⇒ Object
Returns the value of attribute switches.
7
8
9
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 7
def switches
@switches
end
|
Instance Method Details
#attr(name, value) ⇒ Object
30
31
32
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 30
def attr(name, value)
self.current_attributes[name] = value
end
|
#element_tracker_switch(element, currently_in) ⇒ Object
40
41
42
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 40
def element_tracker_switch(element, currently_in)
switches[element] = currently_in
end
|
#end_element(name) ⇒ Object
21
22
23
24
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 21
def end_element(name)
reset_current_attributes!
element_tracker_switch name, false
end
|
#reset_current_attributes! ⇒ Object
26
27
28
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 26
def reset_current_attributes!
self.current_attributes = {}
end
|
#start_element(name) ⇒ Object
17
18
19
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 17
def start_element(name)
element_tracker_switch name, true
end
|
#success? ⇒ Boolean
48
49
50
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 48
def success?
['0', 0].include? status_code
end
|
#switch_active?(*elements) ⇒ Boolean
44
45
46
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 44
def switch_active?(*elements)
elements.flatten.all? { |element| switches[element] == true }
end
|
#value(value) ⇒ Object
34
35
36
37
38
|
# File 'lib/endicia_label_server/parsers/parser_base.rb', line 34
def value(value)
string_value = value.as_s
self.status_code = string_value if switch_active? :Status
self.error_description = string_value if switch_active? :ErrorMessage
end
|