Class: Vines::Stream::State

Inherits:
Object
  • Object
show all
Includes:
Nokogiri::XML, Log, Node
Defined in:
lib/vines/stream/state.rb

Overview

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.

Constant Summary

Constants included from Node

Node::BODY, Node::STREAM

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

body?, namespace, stream?, to_stanza

Methods included from Log

#log, set_log_file

Constructor Details

#initialize(stream, success = nil) ⇒ State

Returns a new instance of State.



15
16
17
# File 'lib/vines/stream/state.rb', line 15

def initialize(stream, success=nil)
  @stream, @success = stream, success
end

Instance Attribute Details

#streamObject

Returns the value of attribute stream.



13
14
15
# File 'lib/vines/stream/state.rb', line 13

def stream
  @stream
end

Instance Method Details

#==(state) ⇒ Object



23
24
25
# File 'lib/vines/stream/state.rb', line 23

def ==(state)
  self.class == state.class
end

#eql?(state) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/vines/stream/state.rb', line 27

def eql?(state)
  state.is_a?(State) && self == state
end

#hashObject



31
32
33
# File 'lib/vines/stream/state.rb', line 31

def hash
  self.class.hash
end

#node(node) ⇒ Object



19
20
21
# File 'lib/vines/stream/state.rb', line 19

def node(node)
  raise 'subclass must implement'
end