Sha256: bea9174d466e89f7c78646f0a466d76856cc172df860c652eefcea8da094d75c

Contents?: true

Size: 774 Bytes

Versions: 17

Compression:

Stored size: 774 Bytes

Contents

module Granify
  class Request
    attr_reader :controller, :command, :custom, :flags, :raw_flags

    def initialize
      @controller = nil
      @flags = ARGV[0..ARGV.size].select { |f| f.start_with?('-') }.map { |f| f.split("=").map &:to_sym } || []

      if ARGV.size > 1
        @controller = ARGV[0].to_sym rescue nil
        @command = ARGV[1].to_sym rescue nil

        if ARGV.size > 2
          @custom = ARGV[2..ARGV.size].select { |p| !p.start_with?('-') }.map &:to_sym || []
          # TODO: parameterize flag key/values
          @flags = ARGV[2..ARGV.size].select { |f| f.start_with?('-') }.map { |f| f.split("=").map &:to_sym } || []
          @raw_flags = ARGV[2..ARGV.size].select { |f| f.start_with?('-') } || []
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
evertils-0.1.15 lib/request.rb
evertils-0.1.14 lib/request.rb
evertils-0.1.13 lib/request.rb
evertils-0.1.12 lib/request.rb
evertils-0.1.11 lib/request.rb
evertils-0.1.9 lib/request.rb
evertils-0.1.8 lib/request.rb
evertils-0.1.7 lib/request.rb
evertils-0.1.6 lib/request.rb
evertils-0.1.5 lib/request.rb
evertils-0.1.4 lib/request.rb
evertils-0.1.3 lib/request.rb
evertils-0.1.2 lib/request.rb
evertils-0.1.1 lib/request.rb
evertils-0.1.0 lib/request.rb
evertils-0.0.11 lib/request.rb
evertils-0.0.10 lib/request.rb