Class: Twterm::DirectMessage
- Inherits:
-
Object
- Object
- Twterm::DirectMessage
- Defined in:
- lib/twterm/direct_message.rb
Defined Under Namespace
Classes: Conversation
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#recipient_id ⇒ Object
readonly
Returns the value of attribute recipient_id.
-
#sender_id ⇒ Object
readonly
Returns the value of attribute sender_id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #date ⇒ Object
-
#initialize(message) ⇒ DirectMessage
constructor
A new instance of DirectMessage.
- #update!(message) ⇒ Object
Constructor Details
#initialize(message) ⇒ DirectMessage
Returns a new instance of DirectMessage.
8 9 10 11 |
# File 'lib/twterm/direct_message.rb', line 8 def initialize() @id = .id update!() end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/twterm/direct_message.rb', line 6 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/twterm/direct_message.rb', line 6 def id @id end |
#recipient_id ⇒ Object (readonly)
Returns the value of attribute recipient_id.
6 7 8 |
# File 'lib/twterm/direct_message.rb', line 6 def recipient_id @recipient_id end |
#sender_id ⇒ Object (readonly)
Returns the value of attribute sender_id.
6 7 8 |
# File 'lib/twterm/direct_message.rb', line 6 def sender_id @sender_id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/twterm/direct_message.rb', line 6 def text @text end |
Instance Method Details
#==(other) ⇒ Object
13 14 15 |
# File 'lib/twterm/direct_message.rb', line 13 def ==(other) other.is_a?(self.class) && id == other.id end |
#date ⇒ Object
17 18 19 20 |
# File 'lib/twterm/direct_message.rb', line 17 def date format = Time.now - @created_at < 86_400 ? '%H:%M:%S' : '%Y-%m-%d %H:%M:%S' @created_at.strftime(format) end |
#update!(message) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/twterm/direct_message.rb', line 22 def update!() @created_at = .created_at.dup.localtime @recipient_id = .recipient.id @sender_id = .sender.id @text = .text self end |