Class: Akane::Receivers::AbstractReceiver
- Inherits:
-
Object
- Object
- Akane::Receivers::AbstractReceiver
- Defined in:
- lib/akane/receivers/abstract_receiver.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(consumer: raise(ArgumentError, 'missing consumer'), account: raise(ArgumentError, 'missing account'), logger: Logger.new($stdout), name: nil, config: {}) ⇒ AbstractReceiver
constructor
A new instance of AbstractReceiver.
- #name ⇒ Object
- #on(kind, &block) ⇒ Object
- #on_delete(&block) ⇒ Object
- #on_event(&block) ⇒ Object
- #on_message(&block) ⇒ Object
- #on_tweet(&block) ⇒ Object
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(consumer: raise(ArgumentError, 'missing consumer'), account: raise(ArgumentError, 'missing account'), logger: Logger.new($stdout), name: nil, config: {}) ⇒ AbstractReceiver
Returns a new instance of AbstractReceiver.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 4 def initialize(consumer: raise(ArgumentError, 'missing consumer'), account: raise(ArgumentError, 'missing account'), logger: Logger.new($stdout), name: nil, config: {}) @consumer = consumer @account = account @logger = logger @config = config @hooks = {} end |
Instance Method Details
#name ⇒ Object
17 18 19 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 17 def name @name ||= @config['name'] || "#{cname}:#{@account[:name]}" end |
#on(kind, &block) ⇒ Object
33 34 35 36 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 33 def on(kind, &block) (@hooks[kind] ||= []) << block self end |
#on_delete(&block) ⇒ Object
39 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 39 def on_delete(&block) on(:delete, &block) end |
#on_event(&block) ⇒ Object
41 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 41 def on_event(&block) on(:event, &block) end |
#on_message(&block) ⇒ Object
40 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 40 def (&block) on(:message, &block) end |
#on_tweet(&block) ⇒ Object
38 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 38 def on_tweet(&block) on(:tweet, &block) end |
#running? ⇒ Boolean
29 30 31 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 29 def running? raise NotImplementedError end |
#start ⇒ Object
21 22 23 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 21 def start raise NotImplementedError end |
#stop ⇒ Object
25 26 27 |
# File 'lib/akane/receivers/abstract_receiver.rb', line 25 def stop raise NotImplementedError end |