Sha256: 835f35546599323e6760d4b93f112f0df7150a0e03d26d8bc28d2beb0918a1c3

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

module Memo
  class Option
    attr_reader :namespace, :is_all

    def initialize(args)
      @args = args.to_a
      @is_all = args.include?("-a") ||
        args.include?("-all")

      case args
      in [*, "-n", namespace, *]
        @namespace = namespace
        @args.delete("-n")
        @args.delete(namespace)
      else
      end
    end

    def [](index)
      @args[index]
    end

    def dir?
      include_any? "-dir", "-d"
    end

    def all?
      include_any? "-all", "-a"
    end

    def copy?
      include_any? "-copy", "-c"
    end

    private

    def include_any?(*args)
      args.map { |a| @args.include?(a) }.any?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ememo-0.1.5 lib/memo/cli/arg/option.rb