Class: HammerCLI::Options::Normalizers::Number

Inherits:
AbstractNormalizer show all
Defined in:
lib/hammer_cli/options/normalizers.rb

Instance Method Summary collapse

Methods inherited from AbstractNormalizer

#complete, #description

Instance Method Details

#format(val) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/hammer_cli/options/normalizers.rb', line 159

def format(val)
  if numeric?(val)
    val.to_i
  else
    raise ArgumentError, _("Numeric value is required.")
  end
end

#numeric?(val) ⇒ Boolean

Returns:

  • (Boolean)


167
168
169
# File 'lib/hammer_cli/options/normalizers.rb', line 167

def numeric?(val)
  Integer(val) != nil rescue false
end