Class: Vmail::Query
- Inherits:
-
Object
- Object
- Vmail::Query
- Defined in:
- lib/vmail/query.rb
Class Method Summary collapse
- .args2string(array) ⇒ Object
-
.parse(args) ⇒ Object
args is an array like ARGV.
Class Method Details
.args2string(array) ⇒ Object
21 22 23 24 25 |
# File 'lib/vmail/query.rb', line 21 def self.args2string(array) array.map {|x| x.to_s.split(/\s+/).size > 1 ? "\"#{x}\"" : x.to_s }.join(' ') end |
.parse(args) ⇒ Object
args is an array like ARGV
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/vmail/query.rb', line 5 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 |