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

Instance Method Details

#has_parameters?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/clamp/parameter/declaration.rb', line 19

def has_parameters?
  !parameters.empty?
end

#inheritable_parametersObject



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, options = {}, &block)
  Parameter::Definition.new(name, description, options).tap do |parameter|
    define_accessors_for(parameter, &block)
    parameters << parameter
  end
end

#parameter_buffer_limitObject



34
35
36
37
38
# File 'lib/clamp/parameter/declaration.rb', line 34

def parameter_buffer_limit
  return 0 unless Clamp.allow_options_after_parameters
  return Float::INFINITY if inheritable_parameters.any?(&:multivalued?)
  inheritable_parameters.size
end

#parametersObject



15
16
17
# File 'lib/clamp/parameter/declaration.rb', line 15

def parameters
  @parameters ||= []
end