Module: Clamp::Parameter::Declaration
- Includes:
- Attribute::Declaration
- Included in:
- Command
- Defined in:
- lib/clamp/parameter/declaration.rb
Overview
Parameter declaration methods.
Instance Method Summary collapse
- #has_parameters? ⇒ Boolean
- #inheritable_parameters ⇒ Object
- #parameter(name, description, options = {}, &block) ⇒ Object
- #parameter_buffer_limit ⇒ Object
- #parameters ⇒ Object
Instance Method Details
#has_parameters? ⇒ Boolean
19 20 21 |
# File 'lib/clamp/parameter/declaration.rb', line 19 def has_parameters? !parameters.empty? end |
#inheritable_parameters ⇒ Object
30 31 32 |
# File 'lib/clamp/parameter/declaration.rb', line 30 def inheritable_parameters superclass_inheritable_parameters + parameters.select(&:inheritable?) end |
#parameter(name, description, options = {}, &block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/clamp/parameter/declaration.rb', line 23 def parameter(name, description, = {}, &block) Parameter::Definition.new(name, description, ).tap do |parameter| define_accessors_for(parameter, &block) parameters << parameter end end |
#parameter_buffer_limit ⇒ Object
34 35 36 37 38 |
# File 'lib/clamp/parameter/declaration.rb', line 34 def parameter_buffer_limit return 0 unless Clamp. return Float::INFINITY if inheritable_parameters.any?(&:multivalued?) inheritable_parameters.size end |
#parameters ⇒ Object
15 16 17 |
# File 'lib/clamp/parameter/declaration.rb', line 15 def parameters @parameters ||= [] end |