Class: Vines::Stream::State

Inherits:
Object
  • Object
show all
Includes:
Nokogiri::XML, Log
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 collapse

BODY =
'body'.freeze
STREAM =
'stream'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

#log

Constructor Details

#initialize(stream, success = nil) ⇒ State

Returns a new instance of State.



17
18
19
# File 'lib/vines/stream/state.rb', line 17

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

Instance Attribute Details

#streamObject

Returns the value of attribute stream.



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

def stream
  @stream
end

Instance Method Details

#==(state) ⇒ Object



25
26
27
# File 'lib/vines/stream/state.rb', line 25

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

#eql?(state) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/vines/stream/state.rb', line 29

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

#hashObject



33
34
35
# File 'lib/vines/stream/state.rb', line 33

def hash
  self.class.hash
end

#node(node) ⇒ Object



21
22
23
# File 'lib/vines/stream/state.rb', line 21

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