Sha256: e146b92231c59bf524ee0d44a40af8f0c268812dee86b30383a65437a60ff1e2

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

# Copyright (C) 2016 Mikio Ikoma

# Predefined (built-in) functions
class Regextest::Front::BuiltinFunctions
  def initialize()
    @functions = set_functions
  end
    
  # find a built-in function
  def find_func(function_name)
    @functions[function_name]
  end
  
  # set built-in functions
  def set_functions
    hash = {
      '_day_' => '(?<__day_year>20(?:(?<__day_leap_year>[02468][048]|[13579][26])|\d\d)){0}(?<__day_month>(?<__day_day31>0?[13578]|1[02])|(?<__day_day30>0?[469]|11)|(?<__day_dayfeb>0?2)){0}(?<__day_day>1\d|(?(<__day_day30>)(?:2\d|30)|(?(<__day_day31>)(?:2\d|3[01])|(?(<__day_leap_year>)2\d|2[0-8])))|0?[1-9]){0}(?<__day_delim>\/){0}(?<_day_>\g<__day_year>\g<__day_delim>\g<__day_month>\g<__day_delim>\g<__day_day>){0}',
      '_jp_fname_' => '(?<_jp_fname_>太郎|花子){0}',
      '_jp_lname_' => '(?<_jp_lname_>山田|佐藤){0}',
      '_fname_' => '(?<_fname_>Joe|Alice){0}',
      '_lname_' => '(?<_lname_>Smith|Brown){0}',
    }
  end
end

# Test suite (execute when this file is specified in command line)
if __FILE__ == $0 
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
regextest-0.1.8 lib/regextest/front/builtin-functions.rb
regextest-0.1.6 lib/regextest/front/builtin-functions.rb
regextest-0.1.5 lib/regextest/front/builtin-functions.rb
regextest-0.1.4 lib/regextest/front/builtin-functions.rb
regextest-0.1.3 lib/regextest/front/builtin-functions.rb
regextest-0.1.2 lib/regextest/front/builtin-functions.rb