Sha256: be1aa4f11ebe632da464655807af0efd06bad1446a712ebdfba4c816a384e2dd

Contents?: true

Size: 659 Bytes

Versions: 3

Compression:

Stored size: 659 Bytes

Contents

module Eco
  class CLI
    class Scripting
      class Argument

        attr_reader :key

        def initialize(key, with_param: false)
          @key        = key
          @with_param = !!with_param
        end

        def args_slice(*args)
          #pp "known arg '#{key}' => included? #{args.include?(key)}"
          return args unless args.include?(key)
          i = args.index(key)
          j = with_param?? i+1 : i
          args - args.slice(i..j)
        end

        def with_param!
          @with_param = true
        end

        def with_param?
          @with_param
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eco-helpers-0.9.2 lib/eco/cli/scripting/argument.rb
eco-helpers-0.9.1 lib/eco/cli/scripting/argument.rb
eco-helpers-0.8.4 lib/eco/cli/scripting/argument.rb