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

#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, type_name

Constructor Details

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

Instance Method Details

#string_to_type(str) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/ctioga2/metabuilder/types/strings.rb', line 73

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

#type_nameObject



69
70
71
# File 'lib/ctioga2/metabuilder/types/strings.rb', line 69

def type_name
  return 'regexp'
end

#type_to_string(val) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/ctioga2/metabuilder/types/strings.rb', line 81

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