Class: Akane::Receivers::AbstractReceiver

Inherits:
Object
  • Object
show all
Defined in:
lib/akane/receivers/abstract_receiver.rb

Direct Known Subclasses

Stream

Instance Method Summary collapse

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 = 
  @logger = logger
  @config = config

  @hooks = {}
end

Instance Method Details

#nameObject



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 on_message(&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

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/akane/receivers/abstract_receiver.rb', line 29

def running?
  raise NotImplementedError
end

#startObject

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/akane/receivers/abstract_receiver.rb', line 21

def start
  raise NotImplementedError
end

#stopObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/akane/receivers/abstract_receiver.rb', line 25

def stop
  raise NotImplementedError
end