Class: Lich::Common::Inventory::Handler Private
- Inherits:
-
Object
- Object
- Lich::Common::Inventory::Handler
- Defined in:
- documented/common/inventory.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Ox SAX handler for a SINGLE isolated inventoryManager line. Collects
decoded item attribute hashes and any parse errors, and flags a
continuation (paginated) response. Mirrors the +error+-callback pattern
in XMLParser because Ox never raises on malformed input -- it
auto-closes and reports damage only through #error.
Instance Attribute Summary collapse
-
#after ⇒ String?
readonly
private
The envelope
aftercursor (continuation response). -
#continuations ⇒ Array<Hash>
readonly
private
Raw attribute hashes, one per
(each carries a rootandlastmarker for a branch not yet sent). -
#errors ⇒ Array<String>
readonly
private
Collected Ox parse-error messages.
-
#items ⇒ Array<Hash>
readonly
private
Raw attribute hashes, one per .
-
#manager_id ⇒ String?
readonly
private
The envelope
id(request id). -
#room_id ⇒ String?
readonly
private
The envelope
roomattribute. -
#root ⇒ String?
readonly
private
The envelope
root(present on a continuation response; must be absent on an initial response). -
#state ⇒ String?
readonly
private
The envelope
state("stale" == interrupted).
Instance Method Summary collapse
- #attr(name, value) ⇒ void private
-
#attrs_done ⇒ void
private
Flush accumulated attributes for the current element.
- #cdata(_value) ⇒ void private
-
#continuation? ⇒ Boolean
private
Whether this response is part of a paginated exchange: it either carries
<continuation>children (more branches to fetch) or is itself a continuation response (has a +root+/+after+ envelope). - #end_element(_name) ⇒ void private
- #error(message, line, column) ⇒ void private
-
#initialize ⇒ Handler
constructor
private
A new instance of Handler.
- #start_element(name) ⇒ void private
- #text(_value) ⇒ void private
Constructor Details
#initialize ⇒ Handler
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.
Returns a new instance of Handler.
688 689 690 691 692 693 694 695 696 697 698 699 |
# File 'documented/common/inventory.rb', line 688 def initialize @items = [] @errors = [] @room_id = nil @manager_id = nil @root = nil @after = nil @state = nil @continuations = [] @element = nil @attributes = nil end |
Instance Attribute Details
#after ⇒ String? (readonly)
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.
Returns the envelope after cursor (continuation response).
679 680 681 |
# File 'documented/common/inventory.rb', line 679 def after @after end |
#continuations ⇒ Array<Hash> (readonly)
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.
Returns raw attribute hashes, one per root and last marker for a branch not yet sent).
686 687 688 |
# File 'documented/common/inventory.rb', line 686 def continuations @continuations end |
#errors ⇒ Array<String> (readonly)
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.
Returns collected Ox parse-error messages.
666 667 668 |
# File 'documented/common/inventory.rb', line 666 def errors @errors end |
#items ⇒ Array<Hash> (readonly)
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.
Returns raw attribute hashes, one per .
663 664 665 |
# File 'documented/common/inventory.rb', line 663 def items @items end |
#manager_id ⇒ String? (readonly)
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.
Returns the envelope id (request id).
672 673 674 |
# File 'documented/common/inventory.rb', line 672 def manager_id @manager_id end |
#room_id ⇒ String? (readonly)
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.
Returns the envelope room attribute.
669 670 671 |
# File 'documented/common/inventory.rb', line 669 def room_id @room_id end |
#root ⇒ String? (readonly)
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.
Returns the envelope root (present on a continuation
response; must be absent on an initial response).
676 677 678 |
# File 'documented/common/inventory.rb', line 676 def root @root end |
#state ⇒ String? (readonly)
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.
Returns the envelope state ("stale" == interrupted).
682 683 684 |
# File 'documented/common/inventory.rb', line 682 def state @state 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.
711 712 713 |
# File 'documented/common/inventory.rb', line 711 def attr(name, value) @attributes[name] = value if @attributes end |
#attrs_done ⇒ 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.
Flush accumulated attributes for the current element.
718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
# File 'documented/common/inventory.rb', line 718 def attrs_done case @element when 'inventoryManager' @manager_id = @attributes['id'] @room_id = @attributes['room'] @root = @attributes['root'] @after = @attributes['after'] @state = @attributes['state'] when 'i' @items << @attributes when 'continuation' @continuations << @attributes end end |
#cdata(_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.
743 |
# File 'documented/common/inventory.rb', line 743 def cdata(_value); end |
#continuation? ⇒ Boolean
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.
Returns whether this response is part of a paginated exchange:
it either carries <continuation> children (more branches to fetch) or
is itself a continuation response (has a +root+/+after+ envelope).
756 757 758 |
# File 'documented/common/inventory.rb', line 756 def continuation? !@continuations.empty? || !@root.nil? || !@after.nil? 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.
735 |
# File 'documented/common/inventory.rb', line 735 def end_element(_name); end |
#error(message, line, column) ⇒ 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.
749 750 751 |
# File 'documented/common/inventory.rb', line 749 def error(, line, column) @errors << "#{} (line #{line}, column #{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.
703 704 705 706 |
# File 'documented/common/inventory.rb', line 703 def start_element(name) @element = name @attributes = {} 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.
739 |
# File 'documented/common/inventory.rb', line 739 def text(_value); end |