Sha256: f0f37b9b8c889634fd8b903518c987382be4845d74de40dda8571569b87d0e60

Contents?: true

Size: 994 Bytes

Versions: 3

Compression:

Stored size: 994 Bytes

Contents

# encoding: utf-8

require 'ruby_jid'

module Adhearsion
  module Rayo
    ##
    # A rayo Ref message. This provides the command ID in response to execution of a command.
    #
    class Ref < RayoNode
      register :ref, :core

      # @return [String] the command URI
      attribute :uri
      def uri=(other)
        super URI(other)
      end

      def scheme
        uri.scheme
      end

      def call_id
        case scheme
        when 'xmpp'
          RubyJID.new(uri.opaque).node
        when nil
          uri.path
        else
          uri.opaque
        end
      end

      def domain
        case scheme
        when 'xmpp'
          RubyJID.new(uri.opaque).domain
        end
      end

      def component_id
        case scheme
        when 'xmpp'
          RubyJID.new(uri.opaque).resource
        else
          call_id
        end
      end

      def rayo_attributes
        {}.tap do |atts|
          atts[:uri] = uri if uri
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adhearsion-3.0.0.rc1 lib/adhearsion/rayo/ref.rb
adhearsion-3.0.0.beta2 lib/adhearsion/rayo/ref.rb
adhearsion-3.0.0.beta1 lib/adhearsion/rayo/ref.rb