Class Tap::Signals::Help
In: lib/tap/signals/help.rb
Parent: Signal

Methods

call   list   process  

Public Instance methods

[Source]

   # File lib/tap/signals/help.rb, line 5
5:       def call(input)
6:         args = convert_to_array(input, ['sig'])
7:         args.empty? ? list : process(*args)
8:       end

[Source]

    # File lib/tap/signals/help.rb, line 10
10:       def list
11:         signals = obj.class.signals
12:         width = signals.keys.collect {|key| key.length }.max
13:         
14:         lines = []
15:         signals.each_pair do |key, signal|
16:           next if key.empty?
17:           
18:           desc = signal.desc.to_s
19:           desc = " # #{desc}" unless desc.empty?
20:           lines << "  /#{key.ljust(width)}#{desc}"
21:         end
22:         
23:         "signals (#{obj.class})\n#{lines.join("\n")}"
24:       end

[Source]

    # File lib/tap/signals/help.rb, line 26
26:       def process(sig)
27:         clas = obj.signal(sig).class
28:         
29:         if clas.respond_to?(:desc)
30:           desc = clas.desc
31:           "#{clas} -- #{desc.to_s}\n#{desc.wrap}"
32:         else
33:           "#{clas} -- no help available"
34:         end
35:       end

[Validate]