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



100
101
102
103
104
105
106
# File 'lib/hammer_cli/options/normalizers.rb', line 100

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

#numeric?(val) ⇒ Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/hammer_cli/options/normalizers.rb', line 108

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