Class: UserChoices::NonListStrategy
- Inherits:
-
AbstractArglistStrategy
- Object
- AbstractArglistStrategy
- UserChoices::NonListStrategy
- Defined in:
- lib/user-choices/arglist-strategies.rb
Overview
General handling for cases where the Arglist isn’t treated as a list, but rather as a single (possibly optional) element. Subclasses handle the optional/non-optional case.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from AbstractArglistStrategy
Instance Method Summary collapse
Methods inherited from AbstractArglistStrategy
#adjust, #apply_claimed_conversions, #arglist_arity_error, #initialize
Constructor Details
This class inherits a constructor from UserChoices::AbstractArglistStrategy
Instance Method Details
#arity ⇒ Object
:nodoc:
144 |
# File 'lib/user-choices/arglist-strategies.rb', line 144 def arity; subclass_responsibility; end |
#claim_conversions(conversions_map) ⇒ Object
155 156 157 158 159 160 |
# File 'lib/user-choices/arglist-strategies.rb', line 155 def claim_conversions(conversions_map) claim_length_check(conversions_map) user_denies(@length_check) { "Don't specify the length of an argument list when it's not treated as an array." } end |
#fill(arglist) ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'lib/user-choices/arglist-strategies.rb', line 146 def fill(arglist) case arglist.length when 0 then # This is not considered an error because another source # might fill in the value. when 1 then @value_holder[@choice] = arglist[0] else user_is_bewildered(arglist_arity_error(arglist.length, self.arity)) end end |