Sha256: 6b914e6346cd875e5b4707473fc0c67509faf23ef16232736f2fe4657f00d2ce

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 Bytes

Contents

require "grok-pure"

class Grok::Match
  attr_accessor :subject
  attr_accessor :grok
  attr_accessor :match

  public
  def initialize
    @captures = nil
  end

  public
  def each_capture(&block)
    @grok.capture(@match, &block)
  end # def each_capture

  public
  def captures
    if @captures.nil?
      @captures = Hash.new { |h,k| h[k] = [] }
      each_capture do |key, val|
        @captures[key] << val
      end
    end
    return @captures
  end # def captures

  public
  def [](name)
    return captures[name]
  end # def []
end # Grok::Match

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jls-grok-0.11.5 lib/grok/pure/match.rb
jls-grok-0.11.4 lib/grok/pure/match.rb
jls-grok-0.11.3 lib/grok/pure/match.rb