Class: Optimist::FloatOption
Overview
Floating point number option class.
Direct Known Subclasses
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
1012 |
# File 'lib/optimist.rb', line 1012 def as_type(param) ; param.to_f ; end |
#parse(paramlist, _neg_given) ⇒ Object
1013 1014 1015 1016 1017 1018 1019 1020 |
# File 'lib/optimist.rb', line 1013 def parse(paramlist, _neg_given) paramlist.map do |pg| pg.map do |param| raise CommandlineError, "option '#{self.name}' needs a floating-point number" unless param.is_a?(Numeric) || param =~ FLOAT_RE as_type(param) end end end |
#type_format ⇒ Object
1011 |
# File 'lib/optimist.rb', line 1011 def type_format ; "=<f>" ; end |