Class: ADN::Message
- Inherits:
-
Object
- Object
- ADN::Message
- Defined in:
- lib/adn/message.rb
Instance Attribute Summary collapse
-
#annotations ⇒ Object
Returns the value of attribute annotations.
-
#channel_id ⇒ Object
Returns the value of attribute channel_id.
- #created_at ⇒ Object
-
#html ⇒ Object
Returns the value of attribute html.
-
#id ⇒ Object
Returns the value of attribute id.
-
#machine_only ⇒ Object
Returns the value of attribute machine_only.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#num_replies ⇒ Object
Returns the value of attribute num_replies.
-
#reply_to ⇒ Object
Returns the value of attribute reply_to.
-
#source ⇒ Object
Returns the value of attribute source.
-
#text ⇒ Object
Returns the value of attribute text.
-
#thread_id ⇒ Object
Returns the value of attribute thread_id.
- #user ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #details ⇒ Object
-
#initialize(raw_message) ⇒ Message
constructor
A new instance of Message.
- #set_values(values) ⇒ Object
Constructor Details
#initialize(raw_message) ⇒ Message
Returns a new instance of Message.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/adn/message.rb', line 25 def initialize() set_values() = id if .length == 2 and .key? :id and .key? :channel_id # If we only have the bare minimum data, # assume we want to get values from the server = details if .has_key? "data" set_values(["data"]) end end end |
Instance Attribute Details
#annotations ⇒ Object
Returns the value of attribute annotations.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def annotations @annotations end |
#channel_id ⇒ Object
Returns the value of attribute channel_id.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def channel_id @channel_id end |
#created_at ⇒ Object
57 58 59 |
# File 'lib/adn/message.rb', line 57 def created_at DateTime.parse(@created_at) end |
#html ⇒ Object
Returns the value of attribute html.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def html @html end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def id @id end |
#machine_only ⇒ Object
Returns the value of attribute machine_only.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def machine_only @machine_only end |
#message_id ⇒ Object
Returns the value of attribute message_id.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def @message_id end |
#num_replies ⇒ Object
Returns the value of attribute num_replies.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def num_replies @num_replies end |
#reply_to ⇒ Object
Returns the value of attribute reply_to.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def reply_to @reply_to end |
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def source @source end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def text @text end |
#thread_id ⇒ Object
Returns the value of attribute thread_id.
5 6 7 |
# File 'lib/adn/message.rb', line 5 def thread_id @thread_id end |
Class Method Details
Instance Method Details
#delete ⇒ Object
65 66 67 68 |
# File 'lib/adn/message.rb', line 65 def delete result = ADN::API::Message.delete(channel_id, id) ADN.create_instance(result["data"], Message) end |
#details ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/adn/message.rb', line 43 def details # if we have a source, then we've loaded # stuff from the server if source value = self.instance_variables.map do |i| [i.to_s.slice(1..-1), self.instance_variable_get(i)] end Hash[value] else ADN::API::Message.by_id(channel_id, ) end end |
#set_values(values) ⇒ Object
70 71 72 73 74 |
# File 'lib/adn/message.rb', line 70 def set_values(values) values.each_pair do |k, v| send("#{k}=", v) if respond_to?("#{k}=") end end |