class RubyAsterisk::Request

Class responsible of building commands structure

Attributes

action[RW]
action_id[RW]
parameters[RW]
response_data[RW]

Public Class Methods

new(action, parameters = {}) click to toggle source
# 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

Protected Class Methods

generate_action_id() click to toggle source
# File lib/ruby-asterisk/request.rb, line 27
def self.generate_action_id
  Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond).to_s(36)
end

Public Instance Methods

commands() click to toggle source
# 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