Sha256: 634dde9a00254308e80fe23315450673f9ee1bba38ab67615f310019b16990f1

Contents?: true

Size: 639 Bytes

Versions: 4

Compression:

Stored size: 639 Bytes

Contents

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

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

      if ARGV.size > 0
        if !ARGV[0].start_with?('-')
          @controller = ARGV[0].to_sym rescue nil
        end
        
        @command = ARGV[1].to_sym rescue nil

        if ARGV.size > 2
          @custom = ARGV[2..ARGV.size].select { |p| !p.start_with?('-') }.map &:to_sym || []
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
evertils-0.1.20 lib/request.rb
evertils-0.1.19 lib/request.rb
evertils-0.1.18 lib/request.rb
evertils-0.1.17 lib/request.rb