Class: Lich::DragonRealms::DRParser::InventoryItemSax
- Inherits:
-
Object
- Object
- Lich::DragonRealms::DRParser::InventoryItemSax
- Defined in:
- documented/dragonrealms/drinfomon/drparser.rb
Overview
Ox::Sax handler that extracts the cmd attribute and item name from the first
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#attr(name, value) ⇒ void
private
Captures the cmd attribute value from a
element. -
#end_element(name) ⇒ void
private
Marks the end of a
element and stops capture. -
#error(_message, _line, _column) ⇒ Object
Trailing prose after is not valid XML.
-
#initialize ⇒ void
constructor
Initializes a new SAX handler for parsing inventory item elements.
-
#start_element(name) ⇒ void
private
Marks the beginning of an XML element.
-
#text(value) ⇒ void
private
Captures text content from inside a
element.
Constructor Details
#initialize ⇒ void
Initializes a new SAX handler for parsing inventory item elements.
Sets up internal state to capture the cmd attribute and item name from
the first
177 178 179 180 181 182 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 177 def initialize @in_d = false @done = false @cmd = nil @name = nil end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
169 170 171 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 169 def cmd @cmd end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
169 170 171 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 169 def name @name end |
Instance Method Details
#attr(name, value) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Captures the cmd attribute value from a
Records the cmd attribute only if currently inside a
205 206 207 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 205 def attr(name, value) @cmd = value if @in_d && name == "cmd" end |
#end_element(name) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Marks the end of a
Exits capture mode after the first
230 231 232 233 234 235 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 230 def end_element(name) return unless @in_d && name == "d" @in_d = false @done = true # ignore any later <d> elements; we only want the leading item end |
#error(_message, _line, _column) ⇒ Object
Trailing prose after is not valid XML. We have already captured the element by the time Ox reports it, so the error is intentionally ignored.
239 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 239 def error(, _line, _column); end |
#start_element(name) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Marks the beginning of an XML element.
Enters capture mode when a
192 193 194 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 192 def start_element(name) @in_d = true if name == "d" && !@done end |
#text(value) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Captures text content from inside a
Records the first text node encountered within a
217 218 219 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 217 def text(value) @name = value if @in_d && @name.nil? end |