Class: CTioga2::MetaBuilder::Types::REListParameter
- Inherits:
-
CTioga2::MetaBuilder::Type
- Object
- CTioga2::MetaBuilder::Type
- CTioga2::MetaBuilder::Types::REListParameter
- Defined in:
- lib/ctioga2/metabuilder/types/lists.rb
Overview
A choice between different symbols based on regular expressions.
Instance Attribute Summary
Attributes inherited from CTioga2::MetaBuilder::Type
#passthrough, #re_shortcuts, #shortcuts, #type
Instance Method Summary collapse
-
#initialize(type) ⇒ REListParameter
constructor
A new instance of REListParameter.
- #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) ⇒ REListParameter
Returns a new instance of REListParameter.
116 117 118 119 120 121 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 116 def initialize(type) super raise "type must have a :list key" unless type.has_key?(:list) # We make a copy for our own purposes. @re_hash = type[:list].dup end |
Instance Method Details
#string_to_type_internal(str) ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 127 def string_to_type_internal(str) for k,v in @re_hash if str =~ /^\s*#{k}\s*$/ return v end end raise IncorrectInput, "Invalid input: #{str} should match " + @re_hash.keys.map {|s| s.to_s}.join(',') end |
#type_name ⇒ Object
123 124 125 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 123 def type_name return 'relist' end |
#type_to_string_internal(val) ⇒ Object
137 138 139 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 137 def type_to_string_internal(val) return val.to_s end |