Sha256: 635ccd8d78fa6da6f24cd02ea41e8e4c261615a74dfc050847ec3c68cd4f1ab7

Contents?: true

Size: 644 Bytes

Versions: 6

Compression:

Stored size: 644 Bytes

Contents

module Vines
  # Utility functions to work with nodes
  module Node

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

    module_function

    # Check if node starts a new stream
    def stream?(node)
      node.name == STREAM && namespace(node) == NAMESPACES[:stream]
    end

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

    # Get the namespace
    def namespace(node)
      namespace = node.namespace
      namespace && namespace.href
    end

    # Convert to stanza
    def to_stanza(node, stream)
      Stanza.from_node(node, stream)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
diaspora-vines-0.2.0.develop.4 lib/vines/node.rb
diaspora-vines-0.2.0.develop.3 lib/vines/node.rb
diaspora-vines-0.2.0.develop.2 lib/vines/node.rb
diaspora-vines-0.2.0.develop.1 lib/vines/node.rb
diaspora-vines-0.1.28 lib/vines/node.rb
diaspora-vines-0.1.27 lib/vines/node.rb