Class: Recheck::Optimist::FloatOption

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

Overview

Floating point number option class.

Direct Known Subclasses

FloatArrayOption

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 Recheck::Optimist::Option

Instance Method Details

#as_type(param) ⇒ Object



1050
1051
1052
# File 'lib/recheck/vendor/optimist.rb', line 1050

def as_type(param)
  param.to_f
end

#parse(paramlist, _neg_given) ⇒ Object



1054
1055
1056
1057
1058
1059
1060
1061
# File 'lib/recheck/vendor/optimist.rb', line 1054

def parse(paramlist, _neg_given)
  paramlist.map do |pg|
    pg.map do |param|
      raise CommandlineError, "option '#{name}' needs a floating-point number" unless param.is_a?(Numeric) || param =~ FLOAT_RE
      as_type(param)
    end
  end
end

#type_formatObject



1046
1047
1048
# File 'lib/recheck/vendor/optimist.rb', line 1046

def type_format
  "=<f>"
end