Class: Tap::Signal

Inherits:
Object
  • Object
show all
Defined in:
lib/tap/signal.rb

Overview

Signal attaches an object and allows a specific method to be triggered through a standard interface.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, &block) ⇒ Signal

Returns a new instance of Signal.



19
20
21
22
# File 'lib/tap/signal.rb', line 19

def initialize(obj, &block)
  @obj = obj
  @block = block
end

Class Attribute Details

.descObject

A description of self



9
10
11
# File 'lib/tap/signal.rb', line 9

def desc
  @desc
end

Instance Attribute Details

#blockObject (readonly)

An optional block, used at the signal’s discretion (normally passed to the method the signal targets on obj).



17
18
19
# File 'lib/tap/signal.rb', line 17

def block
  @block
end

#objObject (readonly)

The object receiving signals through self.



13
14
15
# File 'lib/tap/signal.rb', line 13

def obj
  @obj
end

Instance Method Details

#call(args) ⇒ Object

Calls process with the input args and returns the result.



25
26
27
# File 'lib/tap/signal.rb', line 25

def call(args)
  process(args)
end

#inspectObject



34
35
36
# File 'lib/tap/signal.rb', line 34

def inspect
  "#<#{self.class}:#{object_id}>"
end

#process(args) ⇒ Object

Simply returns the input args.



30
31
32
# File 'lib/tap/signal.rb', line 30

def process(args)
  args
end