Sha256: 9a8130e5327021caa5ecb325ed9164e3cc4b508be843e19c93d98a14cf36a43e

Contents?: true

Size: 592 Bytes

Versions: 112

Compression:

Stored size: 592 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

112 entries across 112 versions & 1 rubygems

Version Path
vmail-2.8.7 lib/vmail/query.rb
vmail-2.8.6 lib/vmail/query.rb
vmail-2.8.5 lib/vmail/query.rb
vmail-2.8.4 lib/vmail/query.rb
vmail-2.8.2 lib/vmail/query.rb
vmail-2.8.1 lib/vmail/query.rb
vmail-2.8.0 lib/vmail/query.rb
vmail-2.7.8 lib/vmail/query.rb
vmail-2.7.7 lib/vmail/query.rb
vmail-2.7.6 lib/vmail/query.rb
vmail-2.7.5 lib/vmail/query.rb
vmail-2.7.4 lib/vmail/query.rb
vmail-2.7.3 lib/vmail/query.rb
vmail-2.7.1 lib/vmail/query.rb
vmail-2.7.0 lib/vmail/query.rb
vmail-2.6.9 lib/vmail/query.rb
vmail-2.6.7 lib/vmail/query.rb
vmail-2.6.6 lib/vmail/query.rb
vmail-2.6.5 lib/vmail/query.rb
vmail-2.6.4 lib/vmail/query.rb