Class: ArgvParser::Option

Inherits:
UnnamedOption show all
Defined in:
lib/ruby-process-controller/argv_parser.rb

Instance Attribute Summary

Attributes inherited from UnnamedOption

#block, #comment, #conditions, #option_is_boolean, #option_name, #short_option_name, #value_is_optional, #value_may_be_array, #value_name

Instance Method Summary collapse

Methods inherited from UnnamedOption

#display

Constructor Details

#initialize(short_option_name, option_name, option_is_boolean, value_is_optional, value_may_be_array, value_name, comment, conditions, block) ⇒ Option

Returns a new instance of Option.



45
46
47
48
49
50
51
# File 'lib/ruby-process-controller/argv_parser.rb', line 45

def initialize short_option_name, option_name, option_is_boolean, value_is_optional, value_may_be_array, value_name, comment, conditions, block
  super option_name, value_is_optional, value_may_be_array, comment, conditions, block
  
  @short_option_name = short_option_name
  @option_is_boolean = option_is_boolean
  @value_name = value_name
end

Instance Method Details

#columnized_displayObject



69
70
71
# File 'lib/ruby-process-controller/argv_parser.rb', line 69

def columnized_display
  [display_short_name, display_name, display_value, comment]
end

#display_nameObject



57
58
59
# File 'lib/ruby-process-controller/argv_parser.rb', line 57

def display_name
  "--#{"[no-]" if option_is_boolean}#{option_name}" if option_name
end

#display_namesObject



53
54
55
# File 'lib/ruby-process-controller/argv_parser.rb', line 53

def display_names
  [display_short_name, display_name].compact * "/"
end

#display_short_nameObject



61
62
63
# File 'lib/ruby-process-controller/argv_parser.rb', line 61

def display_short_name
  "-#{short_option_name}" if short_option_name
end

#display_valueObject



65
66
67
# File 'lib/ruby-process-controller/argv_parser.rb', line 65

def display_value
  "#{"[" if value_is_optional}#{value_name}#{"]" if value_is_optional}#{"..." if value_may_be_array}"
end