Sha256: 51bdb9df07936d50dd43251ecc69149aa0b0a94feab8b1de4d91a89beeabb7e6

Contents?: true

Size: 1.04 KB

Versions: 27

Compression:

Stored size: 1.04 KB

Contents

module Evertils
  class Request
    # Access controller variable property externally
    attr_accessor :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_accessor :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

27 entries across 27 versions & 1 rubygems

Version Path
evertils-2.3.4 lib/evertils/request.rb
evertils-2.3.3 lib/evertils/request.rb
evertils-2.3.2 lib/evertils/request.rb
evertils-2.3.1 lib/evertils/request.rb
evertils-2.3.0 lib/evertils/request.rb
evertils-2.2.4 lib/evertils/request.rb
evertils-2.2.3 lib/evertils/request.rb
evertils-2.2.2 lib/evertils/request.rb
evertils-2.2.1 lib/evertils/request.rb
evertils-2.2.0 lib/evertils/request.rb
evertils-2.1.0 lib/evertils/request.rb
evertils-2.0.2 lib/evertils/request.rb
evertils-2.0.1 lib/evertils/request.rb
evertils-2.0.0 lib/evertils/request.rb
evertils-1.0.12 lib/evertils/request.rb
evertils-1.0.11 lib/evertils/request.rb
evertils-1.0.10 lib/evertils/request.rb
evertils-1.0.9 lib/evertils/request.rb
evertils-1.0.8 lib/evertils/request.rb
evertils-1.0.7 lib/evertils/request.rb