Sha256: 19927ede2d6f7632723e08dd9d301e655b0be3985c2a8a1815506199aaf80bdb

Contents?: true

Size: 948 Bytes

Versions: 12

Compression:

Stored size: 948 Bytes

Contents

# encoding: utf-8

module Blather
  class Stanza
    RAYO_NODE_PATH = "(#{Punchblock::RAYO_NAMESPACES.keys.map { |k| "#{k}:*" }.join("|")})".freeze
    ##
    # @return [Punchblock::RayoNode] a child of RayoNode
    #   representing the Rayo command/event contained within the stanza
    #
    def rayo_node
      @rayo_node ||= begin
        first_child = at_xpath RAYO_NODE_PATH, Punchblock::RAYO_NAMESPACES
        Punchblock::RayoNode.from_xml first_child, nil, component_id, "xmpp:#{from}", delay_timestamp if first_child
      end
    end

    ##
    # @return [String] the call ID this stanza applies to
    #
    def call_id
      from.node
    end

    ##
    # @return [String] the command ID this stanza applies to
    #
    def component_id
      from.resource
    end

  private

    def delay_timestamp
      if delay = self.at_xpath('ns:delay', ns: 'urn:xmpp:delay')
        DateTime.parse(delay[:stamp])
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
punchblock-2.7.5 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.7.3 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.7.2 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.7.1 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.7.0 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.6.0 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.5.3 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.5.2 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.5.1 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.5.0 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.4.2 lib/punchblock/core_ext/blather/stanza.rb
punchblock-2.4.0 lib/punchblock/core_ext/blather/stanza.rb