Class: Optimist::IntegerOption

Inherits:
Option
  • Object
show all
Defined in:
lib/optimist_with_insert_blanks.rb

Overview

Integer number option class.

Direct Known Subclasses

IntegerArrayOption

Instance Attribute Summary

Attributes inherited from Option

#default, #long, #multi_given, #name, #short

Instance Method Summary collapse

Methods inherited from Option

#array_default?, #callback, create, #desc, #description_with_default, #educate, #flag?, get_klass_from_default, get_type_from_disdef, handle_long_opt, handle_short_opt, #initialize, #multi, #multi_arg?, #opts, #opts=, register_alias, #required?, #short?, #single_arg?

Constructor Details

This class inherits a constructor from Optimist::Option

Instance Method Details

#parse(paramlist, _neg_given) ⇒ Object



931
932
933
934
935
936
937
938
939
940
941
942
# File 'lib/optimist_with_insert_blanks.rb', line 931

def parse(paramlist, _neg_given)
  paramlist.map do |pg|
    pg.map do |param|
      unless param.is_a?(Numeric) || param =~ /^-?[\d_]+$/
        raise CommandlineError,
              "option '#{name}' needs an integer"
      end

      param.to_i
    end
  end
end

#type_formatObject



927
928
929
# File 'lib/optimist_with_insert_blanks.rb', line 927

def type_format
  '=<i>'
end