Class: RubyAMI::Response

Inherits:
Object show all
Defined in:
lib/ruby_ami/response.rb

Overview

This is the object containing a response from Asterisk.

Note: not all responses have an ActionID!

Direct Known Subclasses

Event

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

Returns a new instance of Response.



20
21
22
# File 'lib/ruby_ami/response.rb', line 20

def initialize
  @headers = HashWithIndifferentAccess.new
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



16
17
18
# File 'lib/ruby_ami/response.rb', line 16

def action
  @action
end

#eventsObject (readonly)

Returns the value of attribute events.



18
19
20
# File 'lib/ruby_ami/response.rb', line 18

def events
  @events
end

#text_bodyObject

Returns the value of attribute text_body.



16
17
18
# File 'lib/ruby_ami/response.rb', line 16

def text_body
  @text_body
end

Class Method Details

.from_immediate_response(text) ⇒ Object



9
10
11
12
13
# File 'lib/ruby_ami/response.rb', line 9

def from_immediate_response(text)
  new.tap do |instance|
    instance.text_body = text
  end
end

Instance Method Details

#[](arg) ⇒ Object



32
33
34
# File 'lib/ruby_ami/response.rb', line 32

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

#[]=(key, value) ⇒ Object



36
37
38
# File 'lib/ruby_ami/response.rb', line 36

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

#action_idObject



40
41
42
# File 'lib/ruby_ami/response.rb', line 40

def action_id
  @headers['ActionID']
end

#has_text_body?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ruby_ami/response.rb', line 24

def has_text_body?
  !!@text_body
end

#headersObject



28
29
30
# File 'lib/ruby_ami/response.rb', line 28

def headers
  @headers.clone
end