class Regexp

Add-on methods (samples, sample, match_data) for Regexp class @raise [Regextest::RegextestError] if impossible to generate. @raise [Regextest::RegextestFailedToGenerate] if failed to generate. Mainly caused by Regextest’s restrictions. @raise [Regextest::RegextestTimeout] if detected timeout while verification. Option ‘verification: false’ may be workaround. @raise [RuntimeError] if something wrong… mainly caused by Regextest’s bug

Public Instance Methods

match_data(option = {}) click to toggle source

generate match-data object(s) of regexp @param [Hash] option option parameters for sampling @option option [Fixnum] :seed seed for randomization @option option [TrueClass] :verification specify true (or not speficy) if verified using ruby Regexp. @option option [FalseClass] :verification specify false if skip to verify using ruby Regexp. @return [MatchData] if able to generate matched data

# File lib/regextest/regexp.rb, line 32
def match_data(option = {})
  regextest = Regextest.new(self, option)
  result = regextest.generate
end
sample(option = {}) click to toggle source

generate a sample string of regexp @param [Hash] option option parameters for sampling @option option [Fixnum] :seed seed for randomization @option option [TrueClass] :verification specify true (or not speficy) if verified using ruby Regexp. @option option [FalseClass] :verification specify false if skip to verify using ruby Regexp. @return [String] if able to generate matched string

# File lib/regextest/regexp.rb, line 18
def sample(option = {})
  if option[:verification] != false
    match_data(option).string
  else
    match_data(option)
  end
end
to_json() click to toggle source

parse regexp and return json data @return [String] return parsed json string

# File lib/regextest/regexp.rb, line 39
def to_json
  regextest = Regextest.new(self, {})
  regextest.to_json
end