Module: Rodish::Plugins::ContextSensitiveHelp_::CommandMethods

Defined in:
lib/rodish/plugins/_context_sensitive_help.rb

Instance Method Summary collapse

Instance Method Details

#context_help(context) ⇒ Object

Render help with context-sensitive information.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rodish/plugins/_context_sensitive_help.rb', line 24

def context_help(context)
  lines = help_lines(include_context_help: true)
  lines.map! do |line|
    if line.is_a?(ContextHelp)
      line.call(context)
    else
      line
    end
  end
  lines.flatten!
  lines.join("\n")
end

#help_lines(include_context_help: false) ⇒ Object

Exclude ContextHelp lines unless they are explicitly requested.



38
39
40
41
42
# File 'lib/rodish/plugins/_context_sensitive_help.rb', line 38

def help_lines(include_context_help: false)
  lines = super()
  lines.reject!{|l| l.is_a?(ContextHelp)} unless include_context_help
  lines
end