class Skype::Chat::Message

Attributes

body[R]
id[R]
time[R]
user[R]

Public Class Methods

new(id) click to toggle source
# File lib/skype/wrappers/chat.rb, line 38
def initialize(id)
  @id = id.to_i
  if cache = @@cache.get(@id)
    @user = cache[:user]
    @body = cache[:body]
    @time = cache[:time]
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/skype/wrappers/chat.rb, line 62
def to_s
  "[#{time}] <#{user}> #{body} "
end

Private Instance Methods

get_properties() click to toggle source
# File lib/skype/wrappers/chat.rb, line 67
def get_properties
  return if @user and @body and @time
  @user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last rescue @user = ""
  @body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^(CHAT)?MESSAGE #{@id} BODY (.+)$/)[0][1] rescue @body = ""
  @time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
  @@cache.set(@id, {
                :user => @user,
                :body => @body,
                :time => @time
              }, 3600*72)
end