class Executable::Help::Option

Encapsualtes a command line option.

Public Class Methods

new(method) click to toggle source
# File lib/executable/help.rb, line 381
def initialize(method)
  @method = method
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/executable/help.rb, line 421
def <=>(other)
  self.name <=> other.name
end
comment() click to toggle source
# File lib/executable/help.rb, line 389
def comment
  @method.comment
end
description() click to toggle source
# File lib/executable/help.rb, line 393
def description
  @description ||= comment.split("\n").first
end
description=(desc) click to toggle source

Set description manually.

# File lib/executable/help.rb, line 398
def description=(desc)
  @description = desc
end
mark() click to toggle source
# File lib/executable/help.rb, line 426
def mark
  name.to_s.size == 1 ? '-' : '--'
end
name() click to toggle source
# File lib/executable/help.rb, line 385
def name
  @method.name.to_s.chomp('!').chomp('=')
end
parameter() click to toggle source
# File lib/executable/help.rb, line 402
def parameter
  begin
    @method.owner.instance_method(@method.name.to_s.chomp('=') + '?')
    false
  rescue
    param = @method.parameters.first
    param.last if param
  end
end
usage() click to toggle source
# File lib/executable/help.rb, line 413
def usage
  if parameter
    "#{name}=#{parameter.to_s.upcase}"
  else
    "#{name}"
  end
end