Class: HammerCLI::Options::Normalizers::Number
Class Method Summary
collapse
Instance Method Summary
collapse
#complete, #completion_type, #description, inherited
Class Method Details
.common_description ⇒ Object
211
212
213
|
# File 'lib/hammer_cli/options/normalizers.rb', line 211
def common_description
_('Numeric value. Integer')
end
|
.completion_type ⇒ Object
207
208
209
|
# File 'lib/hammer_cli/options/normalizers.rb', line 207
def completion_type
:number
end
|
Instance Method Details
216
217
218
219
220
221
222
|
# File 'lib/hammer_cli/options/normalizers.rb', line 216
def format(val)
if numeric?(val)
val.to_i
else
raise ArgumentError, _("Numeric value is required.")
end
end
|
#numeric?(val) ⇒ Boolean
224
225
226
|
# File 'lib/hammer_cli/options/normalizers.rb', line 224
def numeric?(val)
Integer(val) != nil rescue false
end
|