Class: HammerCLI::Options::Normalizers::Bool
- Inherits:
-
AbstractNormalizer
- Object
- AbstractNormalizer
- HammerCLI::Options::Normalizers::Bool
- Defined in:
- lib/hammer_cli/options/normalizers.rb
Instance Method Summary collapse
Instance Method Details
#complete(value) ⇒ Object
70 71 72 |
# File 'lib/hammer_cli/options/normalizers.rb', line 70 def complete(value) ["yes ", "no "] end |
#description ⇒ Object
55 56 57 |
# File 'lib/hammer_cli/options/normalizers.rb', line 55 def description "One of true/false, yes/no, 1/0." end |
#format(bool) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hammer_cli/options/normalizers.rb', line 59 def format(bool) bool = bool.to_s if bool.downcase.match(/^(true|t|yes|y|1)$/i) return true elsif bool.downcase.match(/^(false|f|no|n|0)$/i) return false else raise ArgumentError, "value must be one of true/false, yes/no, 1/0" end end |