class Vines::Stream::State

The base class of Stream state machines. States know how to process XML nodes and advance to their next valid state or fail the stream.

Constants

BODY
STREAM

Attributes

stream[RW]

Public Class Methods

new(stream, success=nil) click to toggle source
# File lib/vines/stream/state.rb, line 17
def initialize(stream, success=nil)
  @stream, @success = stream, success
end

Public Instance Methods

==(state) click to toggle source
# File lib/vines/stream/state.rb, line 25
def ==(state)
  self.class == state.class
end
eql?(state) click to toggle source
# File lib/vines/stream/state.rb, line 29
def eql?(state)
  state.is_a?(State) && self == state
end
hash() click to toggle source
# File lib/vines/stream/state.rb, line 33
def hash
  self.class.hash
end
node(node) click to toggle source
# File lib/vines/stream/state.rb, line 21
def node(node)
  raise 'subclass must implement'
end

Private Instance Methods

advance() click to toggle source
# File lib/vines/stream/state.rb, line 39
def advance
  stream.advance(@success.new(stream))
end
body?(node) click to toggle source
# File lib/vines/stream/state.rb, line 47
def body?(node)
  node.name == BODY && namespace(node) == NAMESPACES[:http_bind]
end
namespace(node) click to toggle source
# File lib/vines/stream/state.rb, line 51
def namespace(node)
  node.namespace ? node.namespace.href : nil
end
stream?(node) click to toggle source
# File lib/vines/stream/state.rb, line 43
def stream?(node)
  node.name == STREAM && namespace(node) == NAMESPACES[:stream]
end
to_stanza(node) click to toggle source
# File lib/vines/stream/state.rb, line 55
def to_stanza(node)
  Stanza.from_node(node, stream)
end