Class: SkypeApi::ChatMessage
- Inherits:
-
Object
- Object
- SkypeApi::ChatMessage
- Defined in:
- lib/skype_api/chat_message.rb
Constant Summary collapse
- COMMAND =
"CHATMESSAGE"
- METHOD_NAMES =
[:chatname, :body, :status]
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#chatname ⇒ Object
readonly
Returns the value of attribute chatname.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #fifo ⇒ Object
-
#initialize(id = nil) ⇒ ChatMessage
constructor
A new instance of ChatMessage.
- #reply ⇒ Object
- #to_s ⇒ Object
- #update(text) ⇒ Object
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/skype_api/chat_message.rb', line 8 def body @body end |
#chatname ⇒ Object (readonly)
Returns the value of attribute chatname.
8 9 10 |
# File 'lib/skype_api/chat_message.rb', line 8 def chatname @chatname end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/skype_api/chat_message.rb', line 8 def id @id end |
#status ⇒ Object (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
#fifo ⇒ Object
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 |
#reply ⇒ Object
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_s ⇒ Object
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 |