Sha256: 8bfae0e9a6eb3aacf5102264c4b2f62fbd1e9ec2db6da8aaf311a69908421326

Contents?: true

Size: 452 Bytes

Versions: 3

Compression:

Stored size: 452 Bytes

Contents

class Object
  def meta_def(m,&b) #:nodoc:
    (class<<self;self end).send(:define_method,m,&b)
  end
end

class Regexp
  def number_of_captures #:nodoc:
    c, x = 0, self.source.dup.gsub( /\\\(/, "" ).gsub( /\\\)/, "" )
    while( r = /(\([^\)]*\))/.match( x ) )
      c, x = c+1, r.post_match
    end
    c
  end
end

class Hash
  def keys_to_sym #:nodoc:
    self.each do |k, v|
      self.delete(k)
      self[k.to_s.to_sym] = v
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Capcode-0.9.0 lib/capcode/core_ext.rb
Capcode-0.8.9 lib/capcode/core_ext.rb
Capcode-0.8.8 lib/capcode/core_ext.rb