Class: Message

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/campfire/polling_bot/plugins/shared/message.rb

Overview

used by HistoryPlugin, among others

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.last_left(name, time = nil) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/campfire/polling_bot/plugins/shared/message.rb', line 24

def self.last_left(name, time = nil)
  first(:conditions => {
      :person => name,
      :message_type => ['Leave','Kick'],
      :timestamp.lt => (time || Time.now)
    }, :order => [:timestamp.desc])
end

.last_message(name, time = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/campfire/polling_bot/plugins/shared/message.rb', line 16

def self.last_message(name, time = nil)
  first(:conditions => {
      :person => name,
      :message_type.not => 'Enter',
      :timestamp.lt => (time || Time.now)
    }, :order => [:timestamp.desc])
end

Instance Method Details

#visible?Boolean

guess whether the message is still on the screen by counting how many messages there are between it and now

Returns:

  • (Boolean)


34
35
36
# File 'lib/campfire/polling_bot/plugins/shared/message.rb', line 34

def visible?
  self.class.count(:id.gt => id) < 20
end