Class: Choosy::Argument
- Inherits:
-
Object
- Object
- Choosy::Argument
- Defined in:
- lib/choosy/argument.rb
Direct Known Subclasses
Constant Summary collapse
- ZERO_ARITY =
(0 .. 0)
- ONE_ARITY =
(1 .. 1)
- MANY_ARITY =
(1 .. 1000)
Instance Attribute Summary collapse
-
#allowable_values ⇒ Object
Returns the value of attribute allowable_values.
-
#arity ⇒ Object
Returns the value of attribute arity.
-
#cast_to ⇒ Object
Returns the value of attribute cast_to.
-
#metaname ⇒ Object
Returns the value of attribute metaname.
-
#validation_step ⇒ Object
Returns the value of attribute validation_step.
Instance Method Summary collapse
- #boolean! ⇒ Object
- #boolean? ⇒ Boolean
- #finalize! ⇒ Object
-
#initialize ⇒ Argument
constructor
A new instance of Argument.
- #multiple! ⇒ Object
- #multiple? ⇒ Boolean
- #required=(val) ⇒ Object
- #required? ⇒ Boolean
- #restricted? ⇒ Boolean
- #single! ⇒ Object
- #single? ⇒ Boolean
Constructor Details
#initialize ⇒ Argument
Returns a new instance of Argument.
9 10 11 |
# File 'lib/choosy/argument.rb', line 9 def initialize @required = false end |
Instance Attribute Details
#allowable_values ⇒ Object
Returns the value of attribute allowable_values.
7 8 9 |
# File 'lib/choosy/argument.rb', line 7 def allowable_values @allowable_values end |
#arity ⇒ Object
Returns the value of attribute arity.
7 8 9 |
# File 'lib/choosy/argument.rb', line 7 def arity @arity end |
#cast_to ⇒ Object
Returns the value of attribute cast_to.
7 8 9 |
# File 'lib/choosy/argument.rb', line 7 def cast_to @cast_to end |
#metaname ⇒ Object
Returns the value of attribute metaname.
7 8 9 |
# File 'lib/choosy/argument.rb', line 7 def @metaname end |
#validation_step ⇒ Object
Returns the value of attribute validation_step.
7 8 9 |
# File 'lib/choosy/argument.rb', line 7 def validation_step @validation_step end |
Instance Method Details
#boolean! ⇒ Object
37 38 39 |
# File 'lib/choosy/argument.rb', line 37 def boolean! @arity = ZERO_ARITY end |
#boolean? ⇒ Boolean
25 26 27 |
# File 'lib/choosy/argument.rb', line 25 def boolean? @arity == ZERO_ARITY end |
#finalize! ⇒ Object
49 50 51 52 |
# File 'lib/choosy/argument.rb', line 49 def finalize! @arity ||= ZERO_ARITY @cast_to ||= :string end |
#multiple! ⇒ Object
45 46 47 |
# File 'lib/choosy/argument.rb', line 45 def multiple! @arity = MANY_ARITY end |
#multiple? ⇒ Boolean
33 34 35 |
# File 'lib/choosy/argument.rb', line 33 def multiple? @arity == MANY_ARITY end |
#required=(val) ⇒ Object
13 14 15 |
# File 'lib/choosy/argument.rb', line 13 def required=(val) @required = val end |
#required? ⇒ Boolean
17 18 19 |
# File 'lib/choosy/argument.rb', line 17 def required? @required end |
#restricted? ⇒ Boolean
21 22 23 |
# File 'lib/choosy/argument.rb', line 21 def restricted? !allowable_values.nil? && allowable_values.length > 0 end |
#single! ⇒ Object
41 42 43 |
# File 'lib/choosy/argument.rb', line 41 def single! @arity = ONE_ARITY end |
#single? ⇒ Boolean
29 30 31 |
# File 'lib/choosy/argument.rb', line 29 def single? @arity == ONE_ARITY end |