Module: Skype::AbstractObject::Invokers

Included in:
Skype, Skype::AbstractObject
Defined in:
lib/skype/object.rb

Instance Method Summary collapse

Instance Method Details

#invoke_alter(prop, value = nil) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/skype/object.rb', line 150

def invoke_alter prop, value=nil
  cmd = "ALTER #{defined?(self.class::OBJECT_NAME) ? self.class::OBJECT_NAME + ' ' : ''}#{@id ? @id.to_s + ' ' : ''}#{prop}#{value ? ' '+value.to_s : '' }"
  #res = "ALTER #{defined?(self.class::OBJECT_NAME) ? self.class::OBJECT_NAME + ' ' : ''}#{@id ? @id.to_s + ' ' : ''}#{prop}"
  #reg.gsub!(/[\^$.\\\[\]*+{}?|()]/) do |char|
  #  "\\" + char
  #end
  #res = "ALTER #{defined?(self.class::OBJECT_NAME) ? self.class::OBJECT_NAME + ' ' : ''}#{prop}"
  begin
    invoke(cmd)# == res
  rescue Skype::Error::API => e
    e.backtrace.shift
    e.backtrace.shift
    raise e
  end
  true
end

#invoke_echo(cmd) ⇒ Object

invoke_echo “CREATE APPLICATION #@appName” CREATE APPLICATION #@appName -> CREATE APPLICATION #@appName



87
88
89
90
91
92
93
94
95
# File 'lib/skype/object.rb', line 87

def invoke_echo cmd
  begin
    invoke(cmd) == cmd
  rescue Skype::Error::API => e
    e.backtrace.shift
    e.backtrace.shift
    raise e
  end
end

#invoke_get(prop, value = nil) ⇒ Object

invoke_get(“GET USER #@handle SkypeOut”) GET USER #@handle SkypeOut -> USER #@handle SkypeOut (.+)



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/skype/object.rb', line 115

def invoke_get prop, value=nil
  cmd = "GET #{defined?(self.class::OBJECT_NAME) ? self.class::OBJECT_NAME + ' ' : ''}#{@id ? @id.to_s+' ' : ''}#{prop}#{value ? ' ' + value : ''}"
  reg = "#{defined?(self.class::OBJECT_NAME) ? self.class::OBJECT_NAME + ' ' : ''}#{@id ? @id.to_s+' ' : ''}#{prop}#{value ? ' ' + value : ''}".gsub(/[\^$.\\\[\]*+{}?|()]/) do |char|
    "\\" + char
  end
  begin
    tmp = invoke(cmd)
    tmp =~ /^#{reg} (.*)$/m
  rescue Skype::Error::API => e
    e.backtrace.shift
    e.backtrace.shift
    raise e
  end
  return $1
end

#invoke_one(cmd, regExp = cmd) ⇒ Object

invoke_one “GET CHATMESSAGE #@id BODY”, “CHATMESSAGE #@id BODY” GET CHATMESSAGE #@id BODY -> CHATMESSAGE #@id BODY (.+)



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/skype/object.rb', line 99

def invoke_one cmd, regExp=cmd
  regExp.gsub!(/[\^$.\\\[\]*+{}?|()]/) do |char|
    "\\" + char
  end
  begin
    invoke(cmd) =~ /^#{regExp} (.*)$/m
  rescue Skype::Error::API => e
    e.backtrace.shift
    e.backtrace.shift
    raise e
  end
  return $1
end

#invoke_set(prop, value = nil) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/skype/object.rb', line 131

def invoke_set prop,value=nil
  cmd = "SET #{defined?(self.class::OBJECT_NAME) ? self.class::OBJECT_NAME + ' ' : ''}#{@id ? @id.to_s + ' ' : ''}#{prop}#{value ? ' '+value.to_s : '' }"
  reg = "#{defined?(self.class::OBJECT_NAME) ? self.class::OBJECT_NAME + ' ' : ''}#{@id ? @id.to_s + ' ' : ''}#{prop}"
  begin
    str = invoke_one cmd, reg
  rescue Skype::Error::API => e
    e.backtrace.shift
    e.backtrace.shift
    raise e
  end
  #p [self,self.class]
  #if self.class == Module
  #  @property2callcack[prop] ? @property2callback[prop].call(str) : str
  #else
  #  self[prop] ? self.class::V2O[prop].call(str) : str
  #end
  str
end