Sha256: eb7c435e59ef195809414ee8a349ca256d66e703596857a9b666d6ba8c5de2fd

Contents?: true

Size: 634 Bytes

Versions: 42

Compression:

Stored size: 634 Bytes

Contents

require 'shellwords'
module Vmail
  class Query
    # args is an array like ARGV
    def self.parse(args)
      if args.is_a?(String)
        args = Shellwords.shellwords args
      end
      query = if args.empty? 
                [100, 'ALL']
              elsif args.size == 1 && args[0] =~ /^\d+/ 
                [args.shift, "ALL"] 
              elsif args[0] =~ /^\d+/
                args
              else
                [100] + args
              end
      query
    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

42 entries across 42 versions & 1 rubygems

Version Path
vmail-1.6.8 lib/vmail/query.rb
vmail-1.6.7 lib/vmail/query.rb
vmail-1.6.6 lib/vmail/query.rb
vmail-1.6.5 lib/vmail/query.rb
vmail-1.6.4 lib/vmail/query.rb
vmail-1.6.3 lib/vmail/query.rb
vmail-1.6.2 lib/vmail/query.rb
vmail-1.6.1 lib/vmail/query.rb
vmail-1.6.0 lib/vmail/query.rb
vmail-1.5.9 lib/vmail/query.rb
vmail-1.5.8 lib/vmail/query.rb
vmail-1.5.7 lib/vmail/query.rb
vmail-1.5.6 lib/vmail/query.rb
vmail-1.5.5 lib/vmail/query.rb
vmail-1.5.4 lib/vmail/query.rb
vmail-1.5.3 lib/vmail/query.rb
vmail-1.5.2 lib/vmail/query.rb
vmail-1.5.1 lib/vmail/query.rb
vmail-1.5.0 lib/vmail/query.rb
vmail-1.4.9 lib/vmail/query.rb