# File lib/map/options.rb, line 5 def for(arg) options = case arg when Hash arg when Array parse(arg) when String, Symbol {arg => true} else raise(ArgumentError, arg.inspect) unless arg.respond_to?(:to_hash) arg.to_hash end unless options.is_a?(Options) options = Map.for(options) options.extend(Options) end raise unless options.is_a?(Map) options end
# File lib/map/options.rb, line 29 def parse(arg) case arg when Array arguments = arg arguments.extend(Arguments) unless arguments.is_a?(Arguments) options = arguments.options when Hash options = arg options = Options.for(options) else raise(ArgumentError, "`arg` should be an Array or Hash") end end
# File lib/map/options.rb, line 98 def del_opt(opts) [ opts ].flatten.each do |opt| return delete(opt) if has_key?(opt) end nil end
# File lib/map/options.rb, line 106 def del_opts(*opts) opts.flatten.map{|opt| delopt(opt)} opts end
# File lib/map/options.rb, line 67 def get_opt(opts, options = {}) options = Map.for(options.is_a?(Hash) ? options : {:default => options}) default = options[:default] [ opts ].flatten.each do |opt| return fetch(opt) if has_key?(opt) end default end
# File lib/map/options.rb, line 77 def get_opts(*opts) opts.flatten.map{|opt| getopt(opt)} end
# File lib/map/options.rb, line 82 def has_opt(opts) [ opts ].flatten.each do |opt| return true if has_key?(opt) end false end
# File lib/map/options.rb, line 92 def has_opts(*opts) opts.flatten.all?{|opt| hasopt(opt)} end
# File lib/map/options.rb, line 46 def pop arguments.pop if arguments.last.object_id == object_id self end
# File lib/map/options.rb, line 55 def pop! arguments.pop if arguments.last.object_id == object_id self end
# File lib/map/options.rb, line 51 def popped? !(arguments.last.object_id == object_id) end
Generated with the Darkfish Rdoc Generator 2.