Module: Clamp::Option::Declaration
Overview
Option declaration methods.
Instance Method Summary collapse
- #declared_options ⇒ Object
- #find_option(switch) ⇒ Object
- #option(switches, type, description, opts = {}, &block) ⇒ Object
- #recognised_options ⇒ Object
Instance Method Details
#declared_options ⇒ Object
27 28 29 |
# File 'lib/clamp/option/declaration.rb', line 27 def @declared_options ||= [] end |
#find_option(switch) ⇒ Object
23 24 25 |
# File 'lib/clamp/option/declaration.rb', line 23 def find_option(switch) .find { |o| o.handles?(switch) } end |
#option(switches, type, description, opts = {}, &block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/clamp/option/declaration.rb', line 15 def option(switches, type, description, opts = {}, &block) Option::Definition.new(switches, type, description, opts).tap do |option| block ||= option.default_conversion_block define_accessors_for(option, &block) << option end end |
#recognised_options ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/clamp/option/declaration.rb', line 31 def unless @implicit_options_declared ||= false declare_implicit_help_option @implicit_options_declared = true end end |