Class: SkypeMac::Call
- Inherits:
-
Object
- Object
- SkypeMac::Call
- Defined in:
- lib/rb-skypemac/call.rb
Overview
Represents a Skype call. Developer is responsible for calling Call#hangup at the end of each call, whether it was placed by the caller or is an answered call.
Constant Summary collapse
- @@TOGGLE_FLAGS =
[:START, :STOP]
Instance Attribute Summary collapse
-
#call_id ⇒ Object
readonly
Returns the value of attribute call_id.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(call) ⇒ Object
-
#get_video_status ⇒ Object
Returns one of: VIDEO_NONE, VIDEO_SEND_ENABLED, VIDEO_RECV_ENABLED, VIDEO_BOTH_ENABLED.
-
#hangup ⇒ Object
Attempts to hang up a call.
-
#initialize(call_id) ⇒ Call
constructor
Creates a Call object from a call_id.
-
#rcv_video(toggle_flag) ⇒ Object
Accepts :START or :STOP.
-
#send_video(toggle_flag) ⇒ Object
Accepts :START or :STOP.
-
#status ⇒ Object
Retrieves the status of the current call.
Untested.
Constructor Details
#initialize(call_id) ⇒ Call
Creates a Call object from a call_id.
27 28 29 30 |
# File 'lib/rb-skypemac/call.rb', line 27 def initialize(call_id) raise ArgumentError("Cannot pass nil call_id") if call_id.nil? @call_id = call_id end |
Instance Attribute Details
#call_id ⇒ Object (readonly)
Returns the value of attribute call_id.
12 13 14 |
# File 'lib/rb-skypemac/call.rb', line 12 def call_id @call_id end |
Class Method Details
.active_call_ids ⇒ Object
15 16 17 18 |
# File 'lib/rb-skypemac/call.rb', line 15 def Call.active_call_ids r = Skype.send_ :command => "SEARCH ACTIVECALLS" r.gsub(/CALLS /, "").split(", ") end |
.active_calls ⇒ Object
20 21 22 23 |
# File 'lib/rb-skypemac/call.rb', line 20 def Call.active_calls calls = Call.active_call_ids.collect { |id| Call.new id unless id == "COMMAND_PENDING"} calls end |
Instance Method Details
#<=>(call) ⇒ Object
64 65 66 |
# File 'lib/rb-skypemac/call.rb', line 64 def <=>(call) @call_id <=> call.call_id end |
#get_video_status ⇒ Object
Returns one of: VIDEO_NONE, VIDEO_SEND_ENABLED, VIDEO_RECV_ENABLED, VIDEO_BOTH_ENABLED
48 49 50 |
# File 'lib/rb-skypemac/call.rb', line 48 def get_video_status Skype.send_ :command => "get call #{id} video_status" end |
#hangup ⇒ Object
Attempts to hang up a call. Note: If Skype hangs while placing the call, this method could hang indefinitely. <u>Use Skype#Call instead of this method unless you like memory leaks</u>.
Raises SkypeError if an error is reported from the Skype API
35 36 37 38 39 |
# File 'lib/rb-skypemac/call.rb', line 35 def hangup s = Skype.send_ :command => "set call #{@call_id} status finished" raise SkypeError("Error occurred on hangup: #{s.}") if s =~ /ERROR/ s end |
#rcv_video(toggle_flag) ⇒ Object
Accepts :START or :STOP
59 60 61 62 |
# File 'lib/rb-skypemac/call.rb', line 59 def rcv_video(toggle_flag) raise Error.new("Illegal flag: #{toggle_flag}") if not @@TOGGLE_FLAGS.index toggle_flag Skype.send_ :command => "alter call #{id} #{toggle_flag.downcase.to_s}_video_receive" end |
#send_video(toggle_flag) ⇒ Object
Accepts :START or :STOP
53 54 55 56 |
# File 'lib/rb-skypemac/call.rb', line 53 def send_video(toggle_flag) raise Error.new("Illegal flag: #{toggle_flag}") if not @@TOGGLE_FLAGS.index toggle_flag Skype.send_ :command => "alter call #{id} #{toggle_flag.downcase.to_s}_video_send" end |
#status ⇒ Object
Retrieves the status of the current call.
Untested
43 44 45 |
# File 'lib/rb-skypemac/call.rb', line 43 def status Skype.send_ :command => "get call #{@call_id} status" end |