Sha256: a5b16923c918060d2d4a3ceac7f84ad66192bed43ccb552e893eb5b893b92e52
Contents?: true
Size: 870 Bytes
Versions: 2
Compression:
Stored size: 870 Bytes
Contents
require 'slop' module Lita module Extensions class KeywordArguments class Parser attr_reader :args, :spec def initialize(spec, args) @spec = spec @args = args end def parse spec.each { |name, option_spec| add_option(name, option_spec) } parser.parse(args) parser.to_hash end private def add_option(name, spec) opt_args = [] opt_options = {} opt_args << spec[:short] if spec[:short] opt_args << name opt_options[:default] = spec[:default] if spec[:default] opt_options[:optional_argument] = true unless spec[:boolean] opt_args << opt_options parser.on(*opt_args) end def parser @parser ||= Slop.new end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lita-keyword-arguments-1.0.0 | lib/lita/extensions/keyword_arguments/parser.rb |
lita-keyword-arguments-0.0.1 | lib/lita/extensions/keyword_arguments/parser.rb |