module FechUtils
Contains helper functions and static variables used by various Fech
classes.
Constants
- ROW_TYPES
All supported row types pointed to regular expressions that will correctly match that row type in the wild. If multiple matches exist,
Fech
will match the longest regex pattern found.
Public Instance Methods
regexify(label)
click to toggle source
Converts symbols and strings to Regexp objects for use in regex-keyed maps. Assumes that symbols should be matched literally, strings unanchored. @param [String,Symbol,Regexp] label the object to convert to a Regexp
# File lib/fech/fech_utils.rb, line 64 def regexify(label) if label.is_a?(Regexp) Regexp.new(label.source, Regexp::IGNORECASE) elsif label.is_a?(Symbol) if ROW_TYPES.keys.include?(label) ROW_TYPES[label] else Regexp.new("^#{label.to_s}$", Regexp::IGNORECASE) end else Regexp.new(Regexp.escape(label.to_s), Regexp::IGNORECASE) end end