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



107
108
109
110
111
112
113
# File 'lib/hammer_cli/options/normalizers.rb', line 107

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

#numeric?(val) ⇒ Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/hammer_cli/options/normalizers.rb', line 115

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