Module: RegexpMatch::ClassMethods

Included in:
RegexpMatch
Defined in:
app/models/regexp_match.rb

Overview

Normal new- regexp_tree is a RegexpTree and dataToParse is a String that may or may not match Partial match regexp_tree is an Array of RegexpMatches that partially match dataToParse and dataToParse is the String union of that may or may not match better explanation needed here, see tests. Class methods

Instance Method Summary collapse

Instance Method Details

#match_data?(regexp, string_to_match) ⇒ Boolean

Returns:

  • (Boolean)

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/regexp_match.rb', line 21

def match_data?(regexp, string_to_match)
	regexp=canonical_regexp(regexp)
	raise "string_to_match='#{string_to_match.inspect}' of class #{string_to_match.class.name} must be String." unless string_to_match.instance_of?(String)
	if regexp.nil? then
		return false
	else
		raise "regexp=#{regexp.inspect} must be Regexp." unless regexp.instance_of?(Regexp)
		begin
			regexp.match(string_to_match)
		rescue RegexpError
			raise "is this ever executed? regexp=#{regexp.inspect}, string_to_match=#{string_to_match.inspect}"
			return nil
		end #begin/rescue
	end #if
end

#promote(value, dataToParse) ⇒ Object

return superclass instance converted to RegexpMatch Used by [] and other methods shared with superclasses


38
39
40
# File 'app/models/regexp_match.rb', line 38

def promote(value, dataToParse)
	return RegexpMatch.new(value, dataToParse)
end