Module: Parser
- Defined in:
- lib/mailchekka/parser.rb
Defined Under Namespace
Classes: Options
Instance Attribute Summary collapse
-
#options ⇒ Object
writeonly
Sets the attribute options.
Class Method Summary collapse
Instance Attribute Details
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
15 16 17 |
# File 'lib/mailchekka/parser.rb', line 15 def (value) = value end |
Class Method Details
.opt_parser ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mailchekka/parser.rb', line 24 def self.opt_parser @parser ||= OptionParser.new do |parser| parser. = 'Usage: mailchecker [options]' parser.separator '' parser.on('-t', '--host HOST', String, '#Mail service host.') do |host| .host = host end parser.on('-p', '--port PORT', Integer, '#Port on which service runs. Default: 143.') do |port| .port = port end parser.on('-l', '--login LOGIN', String, '#Login needed to execute the script.') do |login| .login = login end parser.on('-x', '--password PASSWORD', String, '#Password needed to execute script.') do |pass| .password = pass end parser.on('-s', '--secure', TrueClass, '#Enable ssl.') do .ssl = true end parser.on('-i', '--interval INTERVAL', Integer, "#Interval at which program checks new mail. Default: 30 seconds.") do |interv| .interval = interv unless interv < 30 end parser.on('-o', '--pop', '#Enables POP3. Default is IMAP.') do .pop = true end parser.on('-h', '--help', 'Prints this help.') do puts parser exit end end end |
.Parse(args) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/mailchekka/parser.rb', line 17 def self.Parse(args) = Options.new args << '-h' if args.empty? opt_parser.parse!(args) end |