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.



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

Returns:

  • (String, nil) —

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



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.

Returns:

  • (Array<String>) —

    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 .

Returns:

  • (Array<Hash>) —

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

Returns:

  • (String, nil) —

    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.

Returns:

  • (String, nil) —

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

Returns:

  • (String, nil) —

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

Returns:

  • (String, nil) —

    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.

Parameters:

  • name (String) —

    attribute name

  • value (String) —

    raw attribute value (not entity-decoded)



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.

Parameters:

  • _value (String) —

    CDATA content (ignored)



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

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



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.

Parameters:

  • _name (String) —

    element name



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.

Parameters:

  • message (String) —

    Ox error message

  • line (Integer) —

    line number

  • column (Integer) —

    column number



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

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



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.

Parameters:

  • _value (String) —

    text content (ignored)



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

def text(_value); end