class DataMetaDom::RegExRoster
Registry for the regexes so we don't repeat those
Attributes
canned[R]
i_to_r[R]
r_to_i[R]
Public Class Methods
ixToVarName(index)
click to toggle source
Converts the given custom RegEx index to the matching Pattern static final variable name
# File lib/dataMetaDom/util.rb, line 198 def ixToVarName(index) "REGEX___#{index}___" end
new()
click to toggle source
sets index to 0, initializes hashes
# File lib/dataMetaDom/util.rb, line 204 def initialize @index = 0 @i_to_r = {} @r_to_i = {} @canned = {} end
Public Instance Methods
register(f)
click to toggle source
adds a new regex to the registry
# File lib/dataMetaDom/util.rb, line 212 def register(f) var = f.name rx = f.regex rx = rx[1..-2] if rx.length > 2 && rx.start_with?('/') && rx.end_with?('/') k = rx.to_sym if CANNED_RX.member?(k) if @canned.has_key?(k) @canned[k] << var else @canned[k] = RegExEntry.new(k, var, f.isRequired) end elsif @r_to_i.has_key?(k) # this regex is already registered, just add the variable @i_to_r[@index] << var else @index += 1 @i_to_r[@index] = RegExEntry.new(k, var, f.isRequired) @r_to_i[k] = @index end end