Class: Choosy::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/choosy/argument.rb

Direct Known Subclasses

Option

Constant Summary collapse

ZERO_ARITY =
(0 .. 0)
ONE_ARITY =
(1 .. 1)
MANY_ARITY =
(1 .. 1000)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArgument

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_valuesObject

Returns the value of attribute allowable_values.



7
8
9
# File 'lib/choosy/argument.rb', line 7

def allowable_values
  @allowable_values
end

#arityObject

Returns the value of attribute arity.



7
8
9
# File 'lib/choosy/argument.rb', line 7

def arity
  @arity
end

#cast_toObject

Returns the value of attribute cast_to.



7
8
9
# File 'lib/choosy/argument.rb', line 7

def cast_to
  @cast_to
end

#metanameObject

Returns the value of attribute metaname.



7
8
9
# File 'lib/choosy/argument.rb', line 7

def metaname
  @metaname
end

#validation_stepObject

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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


17
18
19
# File 'lib/choosy/argument.rb', line 17

def required?
  @required
end

#restricted?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


29
30
31
# File 'lib/choosy/argument.rb', line 29

def single?
  @arity == ONE_ARITY
end