Class: SkypeApi::ChatMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/skype_api/chat_message.rb

Constant Summary collapse

COMMAND =
"CHATMESSAGE"
METHOD_NAMES =
[:chatname, :body, :status]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ ChatMessage

Returns a new instance of ChatMessage.



10
11
12
13
# File 'lib/skype_api/chat_message.rb', line 10

def initialize(id = nil)
  @id = id
  @status, @body, @chatname = nil
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/skype_api/chat_message.rb', line 8

def body
  @body
end

#chatnameObject (readonly)

Returns the value of attribute chatname.



8
9
10
# File 'lib/skype_api/chat_message.rb', line 8

def chatname
  @chatname
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/skype_api/chat_message.rb', line 8

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/skype_api/chat_message.rb', line 8

def status
  @status
end

Instance Method Details

#fifoObject



15
16
17
18
19
# File 'lib/skype_api/chat_message.rb', line 15

def fifo
  self.methods.collect do |method|
    self.send method if /^get_.+$/.match(method.to_s)
  end.compact
end

#replyObject



21
22
23
# File 'lib/skype_api/chat_message.rb', line 21

def reply
  "#{COMMAND} #{@chatname} #{SkypeApi::MsgRequest.reply(@body)}" if @chatname and @body and @status == "RECEIVED"
end

#to_sObject



42
43
44
45
46
47
48
49
# File 'lib/skype_api/chat_message.rb', line 42

def to_s
  text = "<id = #{id.inspect}"
  METHOD_NAMES.each do |name|
    text << ", #{name.to_s} = #{(self.send name).inspect}"
  end
  text << ">"
  text
end

#update(text) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/skype_api/chat_message.rb', line 25

def update(text)
  destination, msg_id, property, *value = text.split
  msg_id = msg_id.to_i
  property = "@#{property.downcase}".to_sym
  value = value.join(' ')
  if query_validate(destination, msg_id, property)
    self.instance_variable_set property, /^\d+$/.match(value) ? value.to_i : value
  end
  self
end