class EacRubyUtils::RegexpParser
def initialize(pattern, &builder_proc)
def initialize(pattern, &builder_proc) @pattern = pattern @builder_proc = builder_proc end
def internal_parse(string)
def internal_parse(string) m = pattern.match(string) if m [true, builder_proc ? builder_proc.call(m) : m] else [false, nil] end end
def parse(string)
def parse(string) internal_parse(string)[1] end
def parse!(string)
def parse!(string) match, result = internal_parse(string) return result if match raise ::ArgumentError, "String \"#{string}\" does not match pattern \"#{pattern}\"" end
def parse?(string)
-
(Boolean)
-
def parse?(string) internal_parse(string).first end