Sha256: 1534634b65b082c7309fbe3615a3c3fdbf0fd68b10094147c7a53411f8f95aba

Contents?: true

Size: 591 Bytes

Versions: 1

Compression:

Stored size: 591 Bytes

Contents

module BBLib
  class OptsParser
    class Toggle < Option

      def extract(index, args)
        value = args[index].to_s
        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.3 lib/bblib/cli/options/toggle.rb