Method: Consoler::Options#to_definition
- Defined in:
- lib/consoler/options.rb
#to_definition ⇒ String
Get the definition for these options
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/consoler/options.rb', line 101 def to_definition definition = '' optional = nil each do |option, i| definition += ' ' if optional.nil? && option.is_optional definition += '[' optional = option.is_optional end definition += option.to_definition # only close when the next option is not optional, or another optional group if option.is_optional && ([i + 1].nil? || optional != [i + 1].is_optional) definition += ']' optional = nil end end definition.strip end |