Class: CTioga2::MetaBuilder::Types::REListParameter

Inherits:
CTioga2::MetaBuilder::Type show all
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

#namespace, #namespace_lookup, #passthrough, #re_shortcuts, #shortcuts, #type

Instance Method Summary collapse

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.



113
114
115
116
117
118
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 113

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

Raises:



124
125
126
127
128
129
130
131
132
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 124

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_nameObject



120
121
122
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 120

def type_name
  return 'relist'
end

#type_to_string_internal(val) ⇒ Object



134
135
136
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 134

def type_to_string_internal(val)
  return val.to_s
end