Sha256: 12751b4f9170b461634bd0bda9a5f183ba39cce7349d9a9d4d6f7f6488e8611d

Contents?: true

Size: 591 Bytes

Versions: 6

Compression:

Stored size: 591 Bytes

Contents

require 'shellwords'
module Vmail
  class Query
    # args is an array like ARGV
    def self.parse(args)
      args = args.dup
      if args.is_a?(String)
        args = Shellwords.shellwords args
      end
      if args.size > 0 && args.first =~ /^\d+/
        args.shift
      end
      query = if args.empty?
                ['ALL']
              else
                args
              end
      query.map {|x| x.to_s.downcase}
    end

    def self.args2string(array)
      array.map {|x|
        x.to_s.split(/\s+/).size > 1 ? "\"#{x}\"" : x.to_s
      }.join(' ')
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vmail-2.9.4 lib/vmail/query.rb
vmail-2.9.3 lib/vmail/query.rb
vmail-2.9.2 lib/vmail/query.rb
vmail-2.9.1 lib/vmail/query.rb
vmail-2.9.0 lib/vmail/query.rb
vmail-2.8.9 lib/vmail/query.rb