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
#allowed_values ⇒ Object
175 176 177 |
# File 'lib/hammer_cli/options/normalizers.rb', line 175 def allowed_values ['yes', 'no', 'true', 'false', '1', '0'] end |
#complete(value) ⇒ Object
194 195 196 |
# File 'lib/hammer_cli/options/normalizers.rb', line 194 def complete(value) allowed_values.map { |v| v + ' ' } end |
#description ⇒ Object
179 180 181 |
# File 'lib/hammer_cli/options/normalizers.rb', line 179 def description _('One of %s.') % ['true/false', 'yes/no', '1/0'].join(', ') end |
#format(bool) ⇒ Object
183 184 185 186 187 188 189 190 191 192 |
# File 'lib/hammer_cli/options/normalizers.rb', line 183 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 %s.') % ['true/false', 'yes/no', '1/0'].join(', ') end end |