Sha256: 21b975035c52f7ae7a2f3077474872f26a956bd754fdade07ebbced04762714c

Contents?: true

Size: 1.04 KB

Versions: 22

Compression:

Stored size: 1.04 KB

Contents

module Evertils
  class Request
    # Access controller variable property externally
    attr_reader :controller
    # Access command variable property externally
    attr_reader :command
    # Access custom variable property externally
    attr_reader :custom
    # Access flags variable property externally
    attr_reader :flags
    # Access raw_flags variable property externally
    attr_reader :raw_flags
    # Access param variable property externally
    attr_reader :param

    # Create the request object, parse ARGV for values
    def initialize
      raise ArgumentError, "ARGV is empty" if ARGV.empty?

      @flags = ARGV.select { |f| f.start_with?('-') }.map { |f| f.split('=').map(&:to_sym) } || []
      @raw_flags = ARGV.select { |f| f.start_with?('-') } || []
      @controller = ARGV[0].to_sym unless ARGV[0].start_with?('-')
      @command = ARGV[1].to_sym unless ARGV[1].nil?

      return unless ARGV.size > 2

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
evertils-0.4.0 lib/evertils/request.rb
evertils-0.3.27 lib/evertils/request.rb
evertils-0.3.26 lib/evertils/request.rb
evertils-0.3.25 lib/evertils/request.rb
evertils-0.3.24 lib/evertils/request.rb
evertils-0.3.23 lib/evertils/request.rb
evertils-0.3.22 lib/evertils/request.rb
evertils-0.3.21 lib/evertils/request.rb
evertils-0.3.20 lib/evertils/request.rb
evertils-0.3.19 lib/evertils/request.rb
evertils-0.3.18 lib/evertils/request.rb
evertils-0.3.17 lib/evertils/request.rb
evertils-0.3.16 lib/evertils/request.rb
evertils-0.3.15 lib/evertils/request.rb
evertils-0.3.14.1 lib/evertils/request.rb
evertils-0.3.14 lib/evertils/request.rb
evertils-0.3.13 lib/evertils/request.rb
evertils-0.3.12 lib/evertils/request.rb
evertils-0.3.11 lib/evertils/request.rb
evertils-0.3.10 lib/evertils/request.rb