Class: FSR::Cmd::Conference
- Defined in:
- lib/fsr/cmd/conference.rb
Constant Summary
Constants inherited from Command
FSR::Cmd::Command::DEFAULT_OPTIONS
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#conference_name ⇒ Object
readonly
Returns the value of attribute conference_name.
-
#digits ⇒ Object
readonly
Returns the value of attribute digits.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#fs_socket ⇒ Object
readonly
Returns the value of attribute fs_socket.
-
#pin ⇒ Object
readonly
Returns the value of attribute pin.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#target_options ⇒ Object
readonly
Returns the value of attribute target_options.
Instance Method Summary collapse
- #arguments ⇒ Object
-
#initialize(fs_socket = nil, args = {}) ⇒ Conference
constructor
A new instance of Conference.
- #raw ⇒ Object
-
#run(api_method = :bgapi) ⇒ Object
Send the command to the event socket, using bgapi by default.
Constructor Details
#initialize(fs_socket = nil, args = {}) ⇒ Conference
Returns a new instance of Conference.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fsr/cmd/conference.rb', line 6 def initialize(fs_socket = nil, args = {}) raise(ArgumentError, "args (Passed: <<<#{args}>>>) must be a hash") unless args.kind_of?(Hash) @conference_name, @pin, @profile, @flags = args.values_at(:conference_name, :pin, :profile, :flags) @action, @target, @target_options = args.values_at(:action, :target, :target_options) @digits = args[:digits] @fs_socket = fs_socket raise(ArgumentError, "Cannot use conference without :conference_name") unless conference_name case @action when :dial raise(ArgumentError, "Cannot dial without :target") unless target if @target_options raise(ArgumentError, ":target_options must be a hash") unless .kind_of?(Hash) end when :dtmf raise(ArgumentError, "Cannot send dtmf without :target") unless target raise(ArgumentError, "Cannot send dtmf without :digits") unless digits when :kick raise(ArgumentError, "Cannot kick without :target") unless target else # go with flow, mate end end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def action @action end |
#conference_name ⇒ Object (readonly)
Returns the value of attribute conference_name.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def conference_name @conference_name end |
#digits ⇒ Object (readonly)
Returns the value of attribute digits.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def digits @digits end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def flags @flags end |
#fs_socket ⇒ Object (readonly)
Returns the value of attribute fs_socket.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def fs_socket @fs_socket end |
#pin ⇒ Object (readonly)
Returns the value of attribute pin.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def pin @pin end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def profile @profile end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def target @target end |
#target_options ⇒ Object (readonly)
Returns the value of attribute target_options.
5 6 7 |
# File 'lib/fsr/cmd/conference.rb', line 5 def @target_options end |
Instance Method Details
#arguments ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fsr/cmd/conference.rb', line 36 def arguments = @target_options.keys.sort { |a,b| a.to_s <=> b.to_s }.map { |k| "%s=%s" % [k, @target_options[k]] }.join(",") if @target_options conference_name << "@#{profile}" if profile conference_name << "+#{pin}" if pin conference_name << "+#{flags}" if flags args = [conference_name] args << action if action if target @target = "{#{}}#{target}" if args << target end args << digits if action == :dtmf args.compact end |
#raw ⇒ Object
53 54 55 |
# File 'lib/fsr/cmd/conference.rb', line 53 def raw ["conference", *arguments].join(" ") end |
#run(api_method = :bgapi) ⇒ Object
Send the command to the event socket, using bgapi by default.
30 31 32 33 34 |
# File 'lib/fsr/cmd/conference.rb', line 30 def run(api_method = :bgapi) conf_command = "%s %s" % [api_method, raw] Log.debug "saying #{conf_command}" @fs_socket.say(conf_command) end |