Class: RubyAsterisk::Request
- Inherits:
-
Object
- Object
- RubyAsterisk::Request
- Defined in:
- lib/ruby-asterisk/request.rb
Overview
Class responsible of building commands structure
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#action_id ⇒ Object
Returns the value of attribute action_id.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#response_data ⇒ Object
Returns the value of attribute response_data.
Instance Method Summary collapse
- #commands ⇒ Object
-
#initialize(action, parameters = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(action, parameters = {}) ⇒ Request
Returns a new instance of Request.
9 10 11 12 13 14 |
# File 'lib/ruby-asterisk/request.rb', line 9 def initialize(action, parameters = {}) self.action = action self.action_id = Request.generate_action_id self.parameters = parameters self.response_data = '' end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
7 8 9 |
# File 'lib/ruby-asterisk/request.rb', line 7 def action @action end |
#action_id ⇒ Object
Returns the value of attribute action_id.
7 8 9 |
# File 'lib/ruby-asterisk/request.rb', line 7 def action_id @action_id end |
#parameters ⇒ Object
Returns the value of attribute parameters.
7 8 9 |
# File 'lib/ruby-asterisk/request.rb', line 7 def parameters @parameters end |
#response_data ⇒ Object
Returns the value of attribute response_data.
7 8 9 |
# File 'lib/ruby-asterisk/request.rb', line 7 def response_data @response_data end |
Instance Method Details
#commands ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/ruby-asterisk/request.rb', line 16 def commands _commands = ["Action: #{self.action}\r\n", "ActionID: #{self.action_id}\r\n"] self.parameters.each do |key, value| _commands<<"#{key.to_s}: #{value.to_s}\r\n" unless value.nil? end _commands[_commands.length - 1] << "\r\n" _commands end |