Class: CTioga2::MetaBuilder::Types::StringOrRegexpParameter

Inherits:
CTioga2::MetaBuilder::Type show all
Defined in:
lib/ctioga2/metabuilder/types/strings.rb

Overview

A String or a regular expression

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, #initialize, #option_parser_long_option, #option_parser_option, #string_to_type, type_name

Constructor Details

This class inherits a constructor from CTioga2::MetaBuilder::Type

Instance Method Details

#string_to_type_internal(str) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/ctioga2/metabuilder/types/strings.rb', line 70

def string_to_type_internal(str)
  if str =~ /^\/(.*)\/$/
    return Regexp.new($1)
  else
    return str
  end
end

#type_nameObject



66
67
68
# File 'lib/ctioga2/metabuilder/types/strings.rb', line 66

def type_name
  return 'regexp'
end

#type_to_string(val) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/ctioga2/metabuilder/types/strings.rb', line 78

def type_to_string(val)
  if val.is_a? String
    return val
  else
    return "/#{val}/"
  end
end