Class: CeilingCat::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/ceiling_cat/event.rb

Direct Known Subclasses

Campfire::Event, IRC::Event

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(room, body, user, opts = {}) ⇒ Event

Returns a new instance of Event.



5
6
7
8
9
10
11
# File 'lib/ceiling_cat/event.rb', line 5

def initialize(room, body, user, opts={})
  @room = room
  @body = body.to_s.strip
  @user = user
  @type = opts[:type]
  @time = opts[:time] || Time.now
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/ceiling_cat/event.rb', line 3

def body
  @body
end

#roomObject

Returns the value of attribute room.



3
4
5
# File 'lib/ceiling_cat/event.rb', line 3

def room
  @room
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/ceiling_cat/event.rb', line 3

def time
  @time
end

#typeObject

assume that all messages are just text unless the specific room type overrides it.



24
25
26
# File 'lib/ceiling_cat/event.rb', line 24

def type
  @type
end

#userObject

Returns the value of attribute user.



3
4
5
# File 'lib/ceiling_cat/event.rb', line 3

def user
  @user
end

Instance Method Details

#handleObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/ceiling_cat/event.rb', line 13

def handle
  @room.plugins.each do |plugin|
    begin
      response = plugin.new(self).handle
      break if response.present?
    rescue => e
      @room.say("Whoops - there was a problem with #{plugin}: #{e}")
    end
  end
end