Module: CommandKit::Examples::ClassMethods

Defined in:
lib/command_kit/examples.rb

Overview

Defines class-level methods.

Instance Method Summary collapse

Instance Method Details

#examples(new_examples = nil) ⇒ Array<String>?

Gets or sets the example commands.

Examples:

examples [
  "-o output.txt path/to/file"
]

Parameters:

  • new_examples (Array<String>, String, nil) (defaults to: nil)

    If a String or Array of Strings is given, it will set the class’es example commands.

Returns:

  • (Array<String>, nil)

    The class’es or superclass’es example commands.



67
68
69
70
71
72
73
74
75
# File 'lib/command_kit/examples.rb', line 67

def examples(new_examples=nil)
  if new_examples
    @examples = Array(new_examples)
  else
    @examples || if superclass.kind_of?(ClassMethods)
                   superclass.examples
                 end
  end
end