Class: Filigree::RegexpPattern

Inherits:
SingleObjectPattern show all
Defined in:
lib/filigree/match.rb

Overview

A pattern that tests a string against a regular expression.

Instance Attribute Summary

Attributes inherited from SingleObjectPattern

#pattern_elem

Instance Method Summary collapse

Methods inherited from SingleObjectPattern

#initialize

Methods included from AbstractClass

#abstract_method, extended, #install_icvars, #new

Methods inherited from BasicPattern

#<=>, #as

Constructor Details

This class inherits a constructor from Filigree::SingleObjectPattern

Instance Method Details

#match?(object, env) ⇒ Boolean

Test the object to see if it matches the wrapped regular expression.

Parameters:

  • object (Object)

    Object to test pattern against

  • env (Object)

    Binding environment

Returns:

  • (Boolean)


406
407
408
409
410
# File 'lib/filigree/match.rb', line 406

def match?(object, env)
	(object.is_a?(String) and (md = @pattern_elem.match(object))).tap do |match|
		env.send("match_data=", md) if match
	end
end

#weightObject



412
413
414
# File 'lib/filigree/match.rb', line 412

def weight
	2
end