Ignore:
Timestamp:
Jul 9, 2020, 8:51:43 AM (4 years ago)
Author:
coas-nagasima
Message:

mrubyを2.1.1に更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/mrblib/onig_regexp.rb

    r321 r439  
    1616  end
    1717
     18  def self.last_match=(match)
     19    @last_match = match
     20  end
     21
    1822  # ISO 15.2.15.7.2
    1923  def initialize_copy(other)
     
    2428  def ===(str)
    2529    not self.match(str).nil?
     30  rescue TypeError
     31    false
    2632  end
    2733
     
    4652  end
    4753
     54  # ISO 15.2.10.5.27
     55  def match(re, pos=0, &block)
     56    re.match(self, pos, &block)
     57  end
     58
     59
    4860  # redefine methods with oniguruma regexp version
    49   [:sub, :gsub, :split, :scan].each do |v|
    50     alias_method "string_#{v}".to_sym, v
    51     alias_method v, "onig_regexp_#{v}".to_sym
     61  %i[sub gsub split scan].each do |v|
     62    alias_method :"string_#{v}", v if method_defined?(v)
     63    alias_method v, :"onig_regexp_#{v}"
    5264  end
     65
     66  alias_method :match?, :onig_regexp_match?
    5367
    5468  alias_method :old_slice, :slice
    5569  alias_method :old_square_brancket, :[]
     70  alias_method :old_square_brancket_equal, :[]=
    5671
    5772  def [](*args)
     
    7893
    7994  alias_method :slice, :[]
     95
     96  def []=(*args)
     97    return old_square_brancket_equal(*args) unless args[0].class == Regexp
     98
     99    n_args = args.size
     100    case n_args
     101    when 2
     102      match = args[0].match(self)
     103      self[match.begin(0)...match.end(0)] = args[1]
     104    when 3
     105      match = args[0].match(self)
     106      n = args[1]
     107      self[match.begin(n)...match.end(n)] = args[2]
     108    else
     109      raise ArgumentError, "wrong number of arguments (#{n_args} for 2..3)"
     110    end
     111
     112    self
     113  end
    80114
    81115  def slice!(*args)
Note: See TracChangeset for help on using the changeset viewer.