Class: Lich::Common::Inventory::Handler Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.



682
683
684
685
686
687
688
689
690
691
692
693
# File 'documented/common/inventory.rb', line 682

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).

Returns:

  • (String, nil) —

    the envelope after cursor (continuation response)



673
674
675
# File 'documented/common/inventory.rb', line 673

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 (each carries a root and last marker for a branch not yet sent).

Returns:

  • (Array<Hash>) —

    raw attribute hashes, one per (each carries a root and last marker for a branch not yet sent)



680
681
682
# File 'documented/common/inventory.rb', line 680

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.

Returns:

  • (Array<String>) —

    collected Ox parse-error messages



660
661
662
# File 'documented/common/inventory.rb', line 660

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 .

Returns:

  • (Array<Hash>) —

    raw attribute hashes, one per



657
658
659
# File 'documented/common/inventory.rb', line 657

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).

Returns:

  • (String, nil) —

    the envelope id (request id)



666
667
668
# File 'documented/common/inventory.rb', line 666

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.

Returns:

  • (String, nil) —

    the envelope room attribute



663
664
665
# File 'documented/common/inventory.rb', line 663

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).

Returns:

  • (String, nil) —

    the envelope root (present on a continuation response; must be absent on an initial response)



670
671
672
# File 'documented/common/inventory.rb', line 670

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).

Returns:

  • (String, nil) —

    the envelope state ("stale" == interrupted)



676
677
678
# File 'documented/common/inventory.rb', line 676

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.

Parameters:

  • name (String) —

    attribute name

  • value (String) —

    raw attribute value (not entity-decoded)



705
706
707
# File 'documented/common/inventory.rb', line 705

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.



712
713
714
715
716
717
718
719
720
721
722
723
724
725
# File 'documented/common/inventory.rb', line 712

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.

Parameters:

  • _value (String) —

    CDATA content (ignored)



737
# File 'documented/common/inventory.rb', line 737

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).

Returns:

  • (Boolean) —

    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).



750
751
752
# File 'documented/common/inventory.rb', line 750

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.

Parameters:

  • _name (String) —

    element name



729
# File 'documented/common/inventory.rb', line 729

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.

Parameters:

  • message (String) —

    Ox error message

  • line (Integer) —

    line number

  • column (Integer) —

    column number



743
744
745
# File 'documented/common/inventory.rb', line 743

def error(message, line, column)
  @errors << "#{message} (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.

Parameters:

  • name (String) —

    element name



697
698
699
700
# File 'documented/common/inventory.rb', line 697

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.

Parameters:

  • _value (String) —

    text content (ignored)



733
# File 'documented/common/inventory.rb', line 733

def text(_value); end