Class: Meteor::Core::Util::PatternCache

Inherits:
Object
  • Object
show all
Defined in:
lib/meteor.rb

Overview

パターンキャッシュクラス

Constant Summary collapse

@@regex_cache =
Hash.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePatternCache

イニシャライザ



2879
2880
# File 'lib/meteor.rb', line 2879

def initialize
end

Class Method Details

.get(regex) ⇒ Regexp .get(regex, option) ⇒ Regexp

パターンを取得する

Overloads:

  • .get(regex) ⇒ Regexp

    Returns パターン.

    Parameters:

    • regex (String)

      正規表現

    Returns:

    • (Regexp)

      パターン

  • .get(regex, option) ⇒ Regexp

    Returns パターン.

    Parameters:

    • regex (String)

      正規表現

    • option (Fixnum)

      オプション

    Returns:

    • (Regexp)

      パターン



2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
# File 'lib/meteor.rb', line 2893

def self.get(*args)
  case args.length
    when ONE
      #get_1(args[0])
      if !@@regex_cache[args[0].to_sym] then
        #if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
        @@regex_cache[args[0].to_sym] = Regexp.new(args[0], Regexp::MULTILINE)
        #else
        #  @@regex_cache[args[0].to_sym] = Regexp.new(args[0], Regexp::MULTILINE,E_UTF8)
        #end
      end
      @@regex_cache[args[0].to_sym]
    when TWO
      #get_2(args[0], args[1])
      if !@@regex_cache[args[0].to_sym] then
        #if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
        @@regex_cache[args[0].to_sym] = Regexp.new(args[0], args[1])
        #else
        #  @@regex_cache[args[0].to_sym] = Regexp.new(args[0], args[1],E_UTF8)
        #end
      end
      @@regex_cache[args[0].to_sym]
    else
      raise ArgumentError
  end
end