Class: Skype::Chat

Inherits:
Object
  • Object
show all
Defined in:
lib/skype/wrappers/chat.rb

Defined Under Namespace

Classes: Message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Chat

Returns a new instance of Chat.



16
17
18
19
20
# File 'lib/skype/wrappers/chat.rb', line 16

def initialize(id)
  @id = id
  @topic = ::Skype.exec("GET CHAT #{@id} TOPIC").scan(/TOPIC (.*)$/)[0][0].toutf8 rescue @topic = ""
  @members = ::Skype.exec("GET CHAT #{@id} MEMBERS").scan(/MEMBERS (.+)$/)[0][0].split(/\s/) rescue @members = []
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/skype/wrappers/chat.rb', line 14

def id
  @id
end

#membersObject (readonly)

Returns the value of attribute members.



14
15
16
# File 'lib/skype/wrappers/chat.rb', line 14

def members
  @members
end

#topicObject (readonly)

Returns the value of attribute topic.



14
15
16
# File 'lib/skype/wrappers/chat.rb', line 14

def topic
  @topic
end

Instance Method Details

#messagesObject



22
23
24
25
26
27
# File 'lib/skype/wrappers/chat.rb', line 22

def messages
  ::Skype.exec("GET CHAT #{@id} RECENTCHATMESSAGES").
    split(/,? /).
    select{|i| i =~ /^\d+$/ }.
    map{|i| Skype::Chat::Message.new i }
end

#post(message) ⇒ Object



29
30
31
# File 'lib/skype/wrappers/chat.rb', line 29

def post(message)
  ::Skype.exec "CHATMESSAGE #{@id} #{message}"
end