Module: Skype

Defined in:
lib/skype.rb,
lib/skype/main.rb,
lib/skype/filter.rb,
lib/skype/version.rb,
lib/skype/platforms/mac.rb,
lib/skype/wrappers/call.rb,
lib/skype/wrappers/chat.rb,
lib/skype/wrappers/error.rb,
lib/skype/platforms/linux.rb

Defined Under Namespace

Modules: Utils Classes: APIError, Call, Chat, Connection

Constant Summary collapse

VERSION =
"0.2.8"
@@config =
{:app_name => "ruby-skype"}
@@filters =
{}

Class Method Summary collapse

Class Method Details

.chatsObject



7
8
9
10
11
# File 'lib/skype/wrappers/chat.rb', line 7

def self.chats
  search("recentchats").
    scan(/\s(#[^\s,]+),?/).
    map{|i| Chat.new i[0] }
end

.config(conf = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/skype/main.rb', line 3

def self.config(conf=nil)
  if conf.kind_of? Hash
    conf.each do |k,v|
      @@config[k.to_sym] = v
    end
  else
    return @@config
  end
end

.exec(command, opts = {:response_filter => true}) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/skype/platforms/mac.rb', line 2

def self.exec(command, opts={:response_filter => true})
  script = %Q{tell application "Skype"
send command "#{Utils.escape command}" script name "#{self.config[:app_name]}"
end tell}
  res = `unset LD_LIBRARY_PATH; unset DYLD_LIBRARY_PATH; /usr/bin/osascript -e '#{script}'`.strip
  res = filter_response res if opts[:response_filter]
  res
end

.filter_response(response_string) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/skype/filter.rb', line 10

def self.filter_response(response_string)
  @@filters.each do |filter, block|
    next unless response_string =~ filter
    response_string = block.call(response_string)
    break
  end
  response_string
end

.method_missing(name, *args) ⇒ Object



13
14
15
# File 'lib/skype/main.rb', line 13

def self.method_missing(name, *args)
  self.exec "#{name.to_s.upcase} #{args.join(' ')}"
end

.response_filter(pattern, &block) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
# File 'lib/skype/filter.rb', line 4

def self.response_filter(pattern, &block)
  raise ArgumentError, "pattern must be instance of Regexp" unless pattern.kind_of? Regexp
  raise ArgumentError, "block not given" unless block_given?
  @@filters[pattern] = block
end