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 from an open
element. -
#end_element(name) ⇒ void
private
Marks the end of a
element and stops parsing after the first one. -
#error(_message, _line, _column) ⇒ Object
Trailing prose after is not valid XML.
-
#initialize ⇒ void
constructor
Initializes the SAX handler with parsing state ready to extract the cmd attribute and item name from the first
element in an inventory line. -
#start_element(name) ⇒ void
private
Records when a
element begins, marking it for attribute and text capture. -
#text(value) ⇒ void
private
Records the item name from the text content of a
element.
Constructor Details
#initialize ⇒ void
Initializes the SAX handler with parsing state ready to extract the cmd
attribute and item name from the first
154 155 156 157 158 159 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 154 def initialize @in_d = false @done = false @cmd = nil @name = nil end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
148 149 150 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 148 def cmd @cmd end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
148 149 150 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 148 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 from an open
176 177 178 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 176 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
196 197 198 199 200 201 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 196 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.
205 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 205 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.
Records when a
166 167 168 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 166 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.
Records the item name from the text content of a
186 187 188 |
# File 'documented/dragonrealms/drinfomon/drparser.rb', line 186 def text(value) @name = value if @in_d && @name.nil? end |