Class: Optimist::IntegerOption

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

Overview

Integer number option class.

Direct Known Subclasses

IntegerArrayOption

Instance Attribute Summary

Attributes inherited from Option

#default, #long, #multi_given, #name, #permitted, #permitted_response, #short

Instance Method Summary collapse

Methods inherited from Option

#array_default?, #callback, create, #desc, #doesnt_need_autogen_short, #educate, #flag?, #format_stdio, #full_description, #initialize, #multi, #multi_arg?, #opts, #opts=, #permitted_type_valid?, #permitted_valid_string, #permitted_value?, register_alias, #required?, #single_arg?, #validate_permitted

Constructor Details

This class inherits a constructor from Optimist::Option

Instance Method Details

#as_type(param) ⇒ Object



1027
# File 'lib/optimist.rb', line 1027

def as_type(param) ; param.to_i ; end

#parse(paramlist, _neg_given) ⇒ Object



1028
1029
1030
1031
1032
1033
1034
1035
# File 'lib/optimist.rb', line 1028

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

#type_formatObject



1026
# File 'lib/optimist.rb', line 1026

def type_format ; "=<i>" ; end