Sha256: 3a184cba4f8d2f271627624ae47b766b8088165b093c4e774371fc10e4414645
Contents?: true
Size: 812 Bytes
Versions: 12
Compression:
Stored size: 812 Bytes
Contents
module Hieracles class Optparse attr_reader :options, :payload def available_options {} end def initialize(array) @options = {} @payload = [] ok = optionkeys while x = array.shift if x[0] == '-' found = ok[x[/[a-z][-_a-z]*$/]] if found if found[:has_args] @options[found[:var]] = array.shift else @options[found[:var]] = true end else array.shift end else @payload << x end end end def optionkeys back = {} available_options.each do |k, v| v[:aliases].each do |a| back[a] = { var: k, has_args: v[:has_arg] } end end back end end end
Version data entries
12 entries across 12 versions & 1 rubygems