Sha256: cad6ae671531f9a763d0765edaa13724d75254457afbf8f3dc5513e93cff8d7a

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 Bytes

Contents

# encoding: utf-8

require 'delegate'

module Adhearsion
  module Translator
    class Asterisk
      class Channel < SimpleDelegator
        NORMALIZATION_REGEXP = /^(?<prefix>Bridge\/)*(?<name>[^<>]*)(?<suffix><.*>)*$/.freeze

        def self.new(other)
          other.is_a?(self) ? other : super
        end

        def name
          matchdata[:name]
        end

        def prefix
          matchdata[:prefix]
        end

        def suffix
          matchdata[:suffix]
        end

        def bridged?
          @bridged ||= (prefix || suffix)
        end

        def to_s
          __getobj__
        end

        private

        def matchdata
          @matchdata ||= __getobj__.match(NORMALIZATION_REGEXP)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adhearsion-3.0.0.rc1 lib/adhearsion/translator/asterisk/channel.rb
adhearsion-3.0.0.beta2 lib/adhearsion/translator/asterisk/channel.rb
adhearsion-3.0.0.beta1 lib/adhearsion/translator/asterisk/channel.rb