Class: Cliqr::Config::Option Private
- Inherits:
-
Named
- Object
- Base
- EventBased
- Named
- Cliqr::Config::Option
- Defined in:
- lib/cliqr/config/option.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Config attributes for a command’s option
Instance Attribute Summary collapse
-
#default ⇒ Object
private
Default value for this option.
-
#operator ⇒ Class<Cliqr::Command::ArgumentOperator>
private
Operation to be applied to the option value after validation.
-
#short ⇒ String
private
Optional short name for the option.
-
#type ⇒ Symbol
private
Optional field that restricts values of this option to a certain type.
Attributes inherited from Named
Attributes inherited from EventBased
Instance Method Summary collapse
-
#boolean? ⇒ Boolean
private
Check if a option is of boolean type.
-
#default? ⇒ Boolean
private
Check if a default value setting is defined.
-
#finalize ⇒ Cliqr::Config::Option
private
Finalize option’s config by adding default values for unset values.
-
#initialize ⇒ Option
constructor
private
Initialize a new config instance for an option with UNSET attribute values.
-
#short? ⇒ Boolean
private
Check if a option’s short name is defined.
-
#type? ⇒ Boolean
private
Check if a option’s type is defined.
Methods inherited from Named
Methods inherited from EventBased
Methods inherited from Base
#set_config, #skip_validation?
Methods included from Validation
#errors, included, #read_attributes, #valid?, #validate, #validations
Methods included from DSL
Constructor Details
#initialize ⇒ Option
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new config instance for an option with UNSET attribute values
42 43 44 45 46 47 48 49 |
# File 'lib/cliqr/config/option.rb', line 42 def initialize super @short = UNSET @type = UNSET @operator = UNSET @default = UNSET end |
Instance Attribute Details
#default ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Default value for this option
39 40 41 |
# File 'lib/cliqr/config/option.rb', line 39 def default @default end |
#operator ⇒ Class<Cliqr::Command::ArgumentOperator>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Operation to be applied to the option value after validation
29 30 31 |
# File 'lib/cliqr/config/option.rb', line 29 def operator @operator end |
#short ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Optional short name for the option
15 16 17 |
# File 'lib/cliqr/config/option.rb', line 15 def short @short end |
#type ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Optional field that restricts values of this option to a certain type
22 23 24 |
# File 'lib/cliqr/config/option.rb', line 22 def type @type end |
Instance Method Details
#boolean? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if a option is of boolean type
83 84 85 |
# File 'lib/cliqr/config/option.rb', line 83 def boolean? @type == :boolean end |
#default? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if a default value setting is defined
90 91 92 |
# File 'lib/cliqr/config/option.rb', line 90 def default? !@default.nil? end |
#finalize ⇒ Cliqr::Config::Option
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finalize option’s config by adding default values for unset values
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cliqr/config/option.rb', line 54 def finalize super @short = Config.get_if_unset(@short, nil) @type = Config.get_if_unset(@type, ANY_ARGUMENT_TYPE) @operator = Util.ensure_instance( Config.get_if_unset(@operator, Cliqr::Command::ArgumentOperator.for_type(@type))) @default = Config.get_if_unset(@default, ARGUMENT_DEFAULTS[@type]) self end |
#short? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if a option’s short name is defined
69 70 71 |
# File 'lib/cliqr/config/option.rb', line 69 def short? !(@short.nil? || @short.empty?) end |
#type? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if a option’s type is defined
76 77 78 |
# File 'lib/cliqr/config/option.rb', line 76 def type? !@type.nil? && @type != :any end |