Class: Tap::Signals::Help
Instance Attribute Summary
Attributes inherited from Tap::Signal
#block, #obj
Instance Method Summary
collapse
Methods inherited from Tap::Signal
#initialize, #inspect
Constructor Details
This class inherits a constructor from Tap::Signal
Instance Method Details
#call(input) ⇒ Object
5
6
7
8
|
# File 'lib/tap/signals/help.rb', line 5
def call(input)
args = convert_to_array(input, ['sig'])
args.empty? ? list : process(*args)
end
|
#list ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/tap/signals/help.rb', line 10
def list
signals = obj.class.signals
width = signals.keys.collect {|key| key.length }.max
lines = []
signals.each_pair do |key, signal|
next if key.empty?
desc = signal.desc.to_s
desc = " # #{desc}" unless desc.empty?
lines << " /#{key.ljust(width)}#{desc}"
end
"signals (#{obj.class})\n#{lines.join("\n")}"
end
|
#process(sig) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/tap/signals/help.rb', line 26
def process(sig)
clas = obj.signal(sig).class
if clas.respond_to?(:desc)
desc = clas.desc
"#{clas} -- #{desc.to_s}\n#{desc.wrap}"
else
"#{clas} -- no help available"
end
end
|