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
139 140 141 |
# File 'lib/hammer_cli/options/normalizers.rb', line 139 def complete(value) ["yes ", "no "] end |
#description ⇒ Object
124 125 126 |
# File 'lib/hammer_cli/options/normalizers.rb', line 124 def description _("One of true/false, yes/no, 1/0.") end |
#format(bool) ⇒ Object
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/hammer_cli/options/normalizers.rb', line 128 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 |