module Todo::Support::OptionsParser
Public Instance Methods
opt(*args, &block)
click to toggle source
# File lib/todo/support/options_parser.rb, line 6 def opt(*args, &block) rules << [args, block] end
parse(args)
click to toggle source
# File lib/todo/support/options_parser.rb, line 10 def parse(args) opts = {} args = parser(opts).parse(args) [args, opts] end
Private Instance Methods
parser(opts)
click to toggle source
# File lib/todo/support/options_parser.rb, line 22 def parser(opts) OptionParser.new do |parser| rules.each do |args, block| parser.on(*args) { |value| block.call(opts, value.strip) } end end end
rules()
click to toggle source
# File lib/todo/support/options_parser.rb, line 18 def rules @rules ||= (superclass.instance_variable_get(:@rules) || []).dup end