Class: Toys::Settings::Type
- Inherits:
-
Object
- Object
- Toys::Settings::Type
- Defined in:
- core-docs/toys/settings.rb
Overview
Defined in the toys-core gem
A type object that checks values.
A Type includes a description string and a testing function. The testing function takes a proposed value and returns either the value itself if it is valid, a converted value if the value can be converted to a valid value, or ILLEGAL_VALUE if the type check failed.
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
The name of the type.
Class Method Summary collapse
-
.for_default_value(value) ⇒ Type
Create and return a Type given a default value.
-
.for_type_spec(type_spec) ⇒ Type
Create and return a Type given a type specification.
Instance Method Summary collapse
-
#call(val) ⇒ Object
Test a value, possibly converting to a legal value.
-
#initialize(description, &block) ⇒ Type
constructor
Create a new Type.
Constructor Details
#initialize(description, &block) ⇒ Type
Create a new Type.
354 355 356 |
# File 'core-docs/toys/settings.rb', line 354 def initialize(description, &block) # Source available in the toys-core gem end |
Instance Attribute Details
#description ⇒ String (readonly)
The name of the type.
362 363 364 |
# File 'core-docs/toys/settings.rb', line 362 def description @description end |
Class Method Details
.for_default_value(value) ⇒ Type
Create and return a Type given a default value. See the Toys::Settings class documentation for the rules.
395 396 397 |
# File 'core-docs/toys/settings.rb', line 395 def for_default_value(value) # Source available in the toys-core gem end |
.for_type_spec(type_spec) ⇒ Type
Create and return a Type given a type specification. See the Toys::Settings class documentation for valid type specifications.
384 385 386 |
# File 'core-docs/toys/settings.rb', line 384 def for_type_spec(type_spec) # Source available in the toys-core gem end |
Instance Method Details
#call(val) ⇒ Object
Test a value, possibly converting to a legal value.
371 372 373 |
# File 'core-docs/toys/settings.rb', line 371 def call(val) # Source available in the toys-core gem end |