Sha256: 68b08f52c1141631331b35cdca022327fe4652765274e49a77f3c20c78ea310c

Contents?: true

Size: 775 Bytes

Versions: 7

Compression:

Stored size: 775 Bytes

Contents

module RubyAMI
  ##
  # This is the object containing a response from Asterisk.
  #
  # Note: not all responses have an ActionID!
  #
  class Response
    class << self
      def from_immediate_response(text)
        new.tap do |instance|
          instance.text_body = text
        end
      end
    end

    attr_accessor :action,
                  :text_body  # For "Response: Follows" sections
    attr_reader   :events

    def initialize
      @headers = HashWithIndifferentAccess.new
    end

    def has_text_body?
      !!@text_body
    end

    def headers
      @headers.clone
    end

    def [](arg)
      @headers[arg]
    end

    def []=(key,value)
      @headers[key] = value
    end

    def action_id
      @headers['ActionID']
    end
  end
end # RubyAMI

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby_ami-1.0.1 lib/ruby_ami/response.rb
ruby_ami-1.0.0 lib/ruby_ami/response.rb
ruby_ami-0.1.5 lib/ruby_ami/response.rb
ruby_ami-0.1.4 lib/ruby_ami/response.rb
ruby_ami-0.1.3 lib/ruby_ami/response.rb
ruby_ami-0.1.2 lib/ruby_ami/response.rb
ruby_ami-0.1.1 lib/ruby_ami/response.rb