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.
11 12 13 |
# File 'lib/choosy/argument.rb', line 11 def initialize @required = false end |
Instance Attribute Details
#allowable_values ⇒ Object
Returns the value of attribute allowable_values.
9 10 11 |
# File 'lib/choosy/argument.rb', line 9 def allowable_values @allowable_values end |
#arity ⇒ Object
Returns the value of attribute arity.
9 10 11 |
# File 'lib/choosy/argument.rb', line 9 def arity @arity end |
#cast_to ⇒ Object
Returns the value of attribute cast_to.
9 10 11 |
# File 'lib/choosy/argument.rb', line 9 def cast_to @cast_to end |
#metaname ⇒ Object
Returns the value of attribute metaname.
9 10 11 |
# File 'lib/choosy/argument.rb', line 9 def @metaname end |
#validation_step ⇒ Object
Returns the value of attribute validation_step.
9 10 11 |
# File 'lib/choosy/argument.rb', line 9 def validation_step @validation_step end |
Instance Method Details
#boolean! ⇒ Object
39 40 41 |
# File 'lib/choosy/argument.rb', line 39 def boolean! @arity = ZERO_ARITY end |
#boolean? ⇒ Boolean
27 28 29 |
# File 'lib/choosy/argument.rb', line 27 def boolean? @arity == ZERO_ARITY end |
#finalize! ⇒ Object
51 52 53 54 |
# File 'lib/choosy/argument.rb', line 51 def finalize! @arity ||= ZERO_ARITY @cast_to ||= :string end |
#multiple! ⇒ Object
47 48 49 |
# File 'lib/choosy/argument.rb', line 47 def multiple! @arity = MANY_ARITY end |
#multiple? ⇒ Boolean
35 36 37 |
# File 'lib/choosy/argument.rb', line 35 def multiple? @arity == MANY_ARITY end |
#required=(val) ⇒ Object
15 16 17 |
# File 'lib/choosy/argument.rb', line 15 def required=(val) @required = val end |
#required? ⇒ Boolean
19 20 21 |
# File 'lib/choosy/argument.rb', line 19 def required? @required end |
#restricted? ⇒ Boolean
23 24 25 |
# File 'lib/choosy/argument.rb', line 23 def restricted? !allowable_values.nil? && allowable_values.length > 0 end |
#single! ⇒ Object
43 44 45 |
# File 'lib/choosy/argument.rb', line 43 def single! @arity = ONE_ARITY end |
#single? ⇒ Boolean
31 32 33 |
# File 'lib/choosy/argument.rb', line 31 def single? @arity == ONE_ARITY end |