Module: Vines::Node

Included in:
Stream::State
Defined in:
lib/vines/node.rb

Overview

Utility functions to work with nodes

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.body?(node) ⇒ Boolean

Check if BOSH body

Returns:

  • (Boolean)


16
17
18
# File 'lib/vines/node.rb', line 16

def body?(node)
  node.name == BODY && namespace(node) == NAMESPACES[:http_bind]
end

.namespace(node) ⇒ Object

Get the namespace



21
22
23
24
# File 'lib/vines/node.rb', line 21

def namespace(node)
  namespace = node.namespace
  namespace && namespace.href
end

.stream?(node) ⇒ Boolean

Check if node starts a new stream

Returns:

  • (Boolean)


11
12
13
# File 'lib/vines/node.rb', line 11

def stream?(node)
  node.name == STREAM && namespace(node) == NAMESPACES[:stream]
end

.to_stanza(node, stream) ⇒ Object

Convert to stanza



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

def to_stanza(node, stream)
  Stanza.from_node(node, stream)
end