Class: RubyAMI::Response
Overview
This is the object containing a response from Asterisk.
Note: not all responses have an ActionID!
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#text_body ⇒ Object
Returns the value of attribute text_body.
Class Method Summary collapse
Instance Method Summary collapse
- #[](arg) ⇒ Object
- #[]=(key, value) ⇒ Object
- #action_id ⇒ Object
- #eql?(o, *fields) ⇒ Boolean (also: #==)
- #has_text_body? ⇒ Boolean
- #headers ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #inspect_attributes ⇒ Object
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
21 22 23 |
# File 'lib/ruby_ami/response.rb', line 21 def initialize @headers = Hash.new end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
17 18 19 |
# File 'lib/ruby_ami/response.rb', line 17 def action @action end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
19 20 21 |
# File 'lib/ruby_ami/response.rb', line 19 def events @events end |
#text_body ⇒ Object
Returns the value of attribute text_body.
17 18 19 |
# File 'lib/ruby_ami/response.rb', line 17 def text_body @text_body end |
Class Method Details
.from_immediate_response(text) ⇒ Object
10 11 12 13 14 |
# File 'lib/ruby_ami/response.rb', line 10 def from_immediate_response(text) new.tap do |instance| instance.text_body = text end end |
Instance Method Details
#[](arg) ⇒ Object
33 34 35 |
# File 'lib/ruby_ami/response.rb', line 33 def [](arg) @headers[arg.to_s] end |
#[]=(key, value) ⇒ Object
37 38 39 |
# File 'lib/ruby_ami/response.rb', line 37 def []=(key,value) @headers[key.to_s] = value end |
#action_id ⇒ Object
41 42 43 |
# File 'lib/ruby_ami/response.rb', line 41 def action_id @headers['ActionID'] end |
#eql?(o, *fields) ⇒ Boolean Also known as: ==
53 54 55 |
# File 'lib/ruby_ami/response.rb', line 53 def eql?(o, *fields) o.is_a?(self.class) && (fields + inspect_attributes).all? { |f| self.__send__(f) == o.__send__(f) } end |
#has_text_body? ⇒ Boolean
25 26 27 |
# File 'lib/ruby_ami/response.rb', line 25 def has_text_body? !!@text_body end |
#headers ⇒ Object
29 30 31 |
# File 'lib/ruby_ami/response.rb', line 29 def headers @headers.clone end |
#inspect ⇒ Object
45 46 47 |
# File 'lib/ruby_ami/response.rb', line 45 def inspect "#<#{self.class} #{inspect_attributes.map { |c| "#{c}=#{self.__send__(c).inspect rescue nil}" }.compact * ', '}>" end |
#inspect_attributes ⇒ Object
49 50 51 |
# File 'lib/ruby_ami/response.rb', line 49 def inspect_attributes [:headers, :text_body, :events, :action] end |