Sha256: d33633d08d7f0f8ba2302b9185c0566eee38e0d7abf77f4cbd87c74a3cac9923

Contents?: true

Size: 593 Bytes

Versions: 7

Compression:

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

7 entries across 7 versions & 1 rubygems

Version Path
vmail-2.9.11 lib/vmail/query.rb
vmail-2.9.10 lib/vmail/query.rb
vmail-2.9.9 lib/vmail/query.rb
vmail-2.9.8 lib/vmail/query.rb
vmail-2.9.7 lib/vmail/query.rb
vmail-2.9.6 lib/vmail/query.rb
vmail-2.9.5 lib/vmail/query.rb