Class: Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/raphael/plugin.rb

Direct Known Subclasses

Command, DeletedTweet, Error, Event, FriendList, Init, Tweet

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &blk) ⇒ Plugin

Returns a new instance of Plugin.



5
6
7
8
# File 'lib/raphael/plugin.rb', line 5

def initialize opts={}, &blk
  @proc = blk
  @opts = opts
end

Class Attribute Details

.pluginsObject (readonly) Also known as: all

Returns the value of attribute plugins.



11
12
13
# File 'lib/raphael/plugin.rb', line 11

def plugins
  @plugins
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



4
5
6
# File 'lib/raphael/plugin.rb', line 4

def opts
  @opts
end

#procObject (readonly)

Returns the value of attribute proc.



4
5
6
# File 'lib/raphael/plugin.rb', line 4

def proc
  @proc
end

Class Method Details

.callback(*args) ⇒ Object



19
20
21
22
23
# File 'lib/raphael/plugin.rb', line 19

def callback *args
  Array(@plugins).each do |plugin|
    plugin.proc.call *args
  end
end

.hook(opts = {}, &blk) ⇒ Object



14
15
16
17
# File 'lib/raphael/plugin.rb', line 14

def hook opts={}, &blk
  @plugins ||= []
  @plugins << self.new(opts, &blk)
end