Class: MetaBuilder::ParameterTypes::FloatRangeParameter

Inherits:
MetaBuilder::ParameterType show all
Defined in:
lib/MetaBuilder/Parameters/numbers.rb

Overview

A Float Range

Constant Summary collapse

RANGE_RE =
/([^:]+):([^:]+)/

Instance Method Summary collapse

Methods inherited from MetaBuilder::ParameterType

#default_value, from_string, get_param_type, get_type, #initialize, #lookup_const, #option_parser_long_option, #option_parser_option, #option_parser_raw, #qt4_create_input_widget, #qt4_get, #string_to_type, #stt_run_hook, #type_name, type_name, #type_to_string, #type_to_variant, #variant_to_type

Constructor Details

This class inherits a constructor from MetaBuilder::ParameterType

Instance Method Details

#string_to_type_internal(str) ⇒ Object

Raises:



54
55
56
57
58
59
# File 'lib/MetaBuilder/Parameters/numbers.rb', line 54

def string_to_type_internal(str)
  raise IncorrectInput, "#{str} is not a valid range" unless 
    str =~ RANGE_RE
  s,e = Float($1), Float($2)
  return Range.new(s,e)
end

#type_to_string_internal(value) ⇒ Object



61
62
63
# File 'lib/MetaBuilder/Parameters/numbers.rb', line 61

def type_to_string_internal(value)
  return "#{value.first.to_s}:#{value.last.to_s}"
end