Sha256: 870f6449530414dcc57e40a1f797a638ac7382592b102a4a31e1b87dcf5038e8
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
require 'clamp/attribute_declaration' require 'clamp/option' module Clamp class Option module Declaration include Clamp::AttributeDeclaration def option(switches, type, description, opts = {}, &block) option = Clamp::Option.new(switches, type, description, opts) my_declared_options << option define_accessors_for(option, &block) end def has_options? !declared_options.empty? end def find_option(switch) recognised_options.find { |o| o.handles?(switch) } end def declared_options my_declared_options + inherited_declared_options end private def recognised_options declared_options + standard_options end def my_declared_options @my_declared_options ||= [] end def inherited_declared_options if superclass.respond_to?(:declared_options) superclass.declared_options else [] end end HELP_OPTION = Clamp::Option.new("--help", :flag, "print help", :attribute_name => :help_requested) def standard_options [HELP_OPTION] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clamp-0.1.8 | lib/clamp/option/declaration.rb |
clamp-0.1.7 | lib/clamp/option/declaration.rb |