Class: CTioga2::MetaBuilder::Types::ListParameter
- Inherits:
-
CTioga2::MetaBuilder::Type
- Object
- CTioga2::MetaBuilder::Type
- CTioga2::MetaBuilder::Types::ListParameter
- Defined in:
- lib/ctioga2/metabuilder/types/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 Attribute Summary
Attributes inherited from CTioga2::MetaBuilder::Type
#passthrough, #re_shortcuts, #shortcuts, #type
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 CTioga2::MetaBuilder::Type
#boolean?, #default_value, from_string, get_param_type, get_type, #option_parser_long_option, #option_parser_option, #string_to_type, type_name, #type_to_string
Constructor Details
#initialize(type) ⇒ ListParameter
Returns a new instance of ListParameter.
85 86 87 88 89 90 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 85 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
96 97 98 99 100 101 102 103 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 96 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
92 93 94 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 92 def type_name return 'list' end |
#type_to_string_internal(val) ⇒ Object
105 106 107 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 105 def type_to_string_internal(val) return val.to_s end |