Sha256: 00c2926197a180be5619169230ef54a892942bd52dcb91ed85abb8af4415350b

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

module BBLib
  class OptsParser
    class Toggle < Option

      def extract(index, args)
        value = args[index]
        if value =~ /^\-[\w\d]$/ || flags.include?(value)
          args.delete_at(index)
        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

      protected

      def simple_setup
        self.default = false
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bblib-2.0.1 lib/bblib/cli/options/toggle.rb