Class: Twterm::DirectMessage
- Inherits:
-
Object
- Object
- Twterm::DirectMessage
- Defined in:
- lib/twterm/direct_message.rb
Defined Under Namespace
Classes: Conversation
Constant Summary collapse
- @@instances =
{}
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 ⇒ Object
readonly
Returns the value of attribute recipient.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
-
#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.
- #matches?(q) ⇒ Boolean
- #update!(message) ⇒ Object
Constructor Details
#initialize(message) ⇒ DirectMessage
10 11 12 13 14 15 |
# File 'lib/twterm/direct_message.rb', line 10 def initialize() @id = .id update!() @@instances[id] = self 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 ⇒ Object (readonly)
Returns the value of attribute recipient.
6 7 8 |
# File 'lib/twterm/direct_message.rb', line 6 def recipient @recipient end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
6 7 8 |
# File 'lib/twterm/direct_message.rb', line 6 def sender @sender 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
17 18 19 |
# File 'lib/twterm/direct_message.rb', line 17 def ==(other) other.is_a?(self.class) && id == other.id end |
#date ⇒ Object
21 22 23 24 |
# File 'lib/twterm/direct_message.rb', line 21 def date format = Time.now - @created_at < 86_400 ? '%H:%M:%S' : '%Y-%m-%d %H:%M:%S' @created_at.strftime(format) end |
#matches?(q) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/twterm/direct_message.rb', line 26 def matches?(q) [ sender.name, sender.screen_name, text ].map(&:downcase).any? { |x| x.include?(q) } end |