Class: MetaBuilder::ParameterTypes::ListParameter
- Inherits:
-
MetaBuilder::ParameterType
- Object
- MetaBuilder::ParameterType
- MetaBuilder::ParameterTypes::ListParameter
- Defined in:
- lib/MetaBuilder/Parameters/lists.rb
Overview
A list of symbols. A hash :list must be provided that states the correspondance between the legal symbols that can be accepted by this parameter and their “english” name. This parameter can typically be used to prompt the user for different choices.
Instance Method Summary collapse
-
#initialize(type) ⇒ ListParameter
constructor
A new instance of ListParameter.
- #string_to_type_internal(str) ⇒ Object
- #type_name ⇒ Object
- #type_to_string_internal(val) ⇒ Object
Methods inherited from MetaBuilder::ParameterType
#default_value, from_string, get_param_type, get_type, #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_to_string, #type_to_variant, #variant_to_type
Constructor Details
#initialize(type) ⇒ ListParameter
Returns a new instance of ListParameter.
74 75 76 77 78 79 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 74 def initialize(type) super raise "type must have a :list key" unless type.has_key?(:list) # We make a copy for our own purposes. @hash = type[:list].dup end |
Instance Method Details
#string_to_type_internal(str) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 85 def string_to_type_internal(str) if @hash.has_key?(str.to_sym) return str.to_sym else raise IncorrectInput, "Invalid input: #{str} should be one of " + @hash.keys.map {|s| s.to_s}.join(',') end end |
#type_name ⇒ Object
81 82 83 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 81 def type_name return 'list' end |
#type_to_string_internal(val) ⇒ Object
94 95 96 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 94 def type_to_string_internal(val) return val.to_s end |