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.



11
12
13
# File 'lib/choosy/argument.rb', line 11

def initialize
  @required = false
end

Instance Attribute Details

#allowable_valuesObject

Returns the value of attribute allowable_values.



9
10
11
# File 'lib/choosy/argument.rb', line 9

def allowable_values
  @allowable_values
end

#arityObject

Returns the value of attribute arity.



9
10
11
# File 'lib/choosy/argument.rb', line 9

def arity
  @arity
end

#cast_toObject

Returns the value of attribute cast_to.



9
10
11
# File 'lib/choosy/argument.rb', line 9

def cast_to
  @cast_to
end

#metanameObject

Returns the value of attribute metaname.



9
10
11
# File 'lib/choosy/argument.rb', line 9

def metaname
  @metaname
end

#validation_stepObject

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

Returns:

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

Returns:

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

Returns:

  • (Boolean)


19
20
21
# File 'lib/choosy/argument.rb', line 19

def required?
  @required
end

#restricted?Boolean

Returns:

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

Returns:

  • (Boolean)


31
32
33
# File 'lib/choosy/argument.rb', line 31

def single?
  @arity == ONE_ARITY
end