Class: BBLib::OptsParser::Toggle
- Defined in:
- lib/bblib/cli/options/toggle.rb
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from Option
#flag_match?, #multi_value?, #retrieve, #split, #to_s, types, #valid!, #valid?
Methods included from TypeInit
Methods included from Effortless
Instance Method Details
#extract(index, args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bblib/cli/options/toggle.rb', line 5 def extract(index, args) value = args[index].to_s if value =~ /^\-[\w\d]$|^\-{2}/ || flags.include?(value) args[index] = nil elsif value =~ /^\-[\w\d]+$/ flag = flags.find do |flag| next unless flag =~ /^\-[\w\d]$/ value.include?(flag[1]) end args[index] = value.sub(flag[1], '') end true end |