Class: SkypeScriptInvoker
- Inherits:
-
Object
- Object
- SkypeScriptInvoker
- Defined in:
- lib/skype_script_invoker.rb
Constant Summary collapse
- @@SCRIPT_PATH =
File.join(File.dirname(__FILE__), "../scripts/")
Instance Attribute Summary collapse
-
#target_chat_id ⇒ Object
Returns the value of attribute target_chat_id.
Instance Method Summary collapse
- #get_chat_id_for_topic(target_topic = "dummy_stuff") ⇒ Object
- #get_chats ⇒ Object
- #get_topic_for_chat(chat_id) ⇒ Object
-
#initialize(topic) ⇒ SkypeScriptInvoker
constructor
A new instance of SkypeScriptInvoker.
- #send_message(message) ⇒ Object
Constructor Details
#initialize(topic) ⇒ SkypeScriptInvoker
Returns a new instance of SkypeScriptInvoker.
7 8 9 10 |
# File 'lib/skype_script_invoker.rb', line 7 def initialize(topic) ## Initilize the chat_id @target_chat_id = get_chat_id_for_topic topic end |
Instance Attribute Details
#target_chat_id ⇒ Object
Returns the value of attribute target_chat_id.
3 4 5 |
# File 'lib/skype_script_invoker.rb', line 3 def target_chat_id @target_chat_id end |
Instance Method Details
#get_chat_id_for_topic(target_topic = "dummy_stuff") ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/skype_script_invoker.rb', line 20 def get_chat_id_for_topic(target_topic ="dummy_stuff") found_chat_id = nil chats = get_chats chats.gsub! "CHATS ", "" chats.split(",").each do |chat_id| details = (get_topic_for_chat chat_id).chomp.split("TOPIC ") topic = details[1].chomp if details.size > 1 found_chat_id = chat_id if topic == target_topic end found_chat_id end |
#get_chats ⇒ Object
12 13 14 |
# File 'lib/skype_script_invoker.rb', line 12 def get_chats `osascript #{@@SCRIPT_PATH}skype_get_chats.APPLESCRIPT` end |
#get_topic_for_chat(chat_id) ⇒ Object
16 17 18 |
# File 'lib/skype_script_invoker.rb', line 16 def get_topic_for_chat(chat_id) `osascript #{@@SCRIPT_PATH}skype_get_topic_for_chat.APPLESCRIPT '#{chat_id}'` end |
#send_message(message) ⇒ Object
35 36 37 |
# File 'lib/skype_script_invoker.rb', line 35 def () `osascript #{@@SCRIPT_PATH}skype_send_message.APPLESCRIPT '#{@target_chat_id}' '#{}'` unless @target_chat_id.nil? end |