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



150
151
152
153
154
155
156
# File 'lib/hammer_cli/options/normalizers.rb', line 150

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

#numeric?(val) ⇒ Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/hammer_cli/options/normalizers.rb', line 158

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