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



84
85
86
87
88
89
90
# File 'lib/hammer_cli/options/normalizers.rb', line 84

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

#numeric?(val) ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/hammer_cli/options/normalizers.rb', line 92

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