Class: RegexpExpressionFactory
- Inherits:
-
Object
- Object
- RegexpExpressionFactory
- Includes:
- Logue::Loggable
- Defined in:
- lib/glark/match/re_factory.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #create_expression(pattern, negated = false) ⇒ Object
-
#initialize(exprspec) ⇒ RegexpExpressionFactory
constructor
A new instance of RegexpExpressionFactory.
Constructor Details
#initialize(exprspec) ⇒ RegexpExpressionFactory
Returns a new instance of RegexpExpressionFactory.
17 18 19 20 21 22 23 24 25 |
# File 'lib/glark/match/re_factory.rb', line 17 def initialize exprspec @count = 0 @extended = exprspec[:extended] @extract_matches = exprspec[:extract_matches] @ignorecase = exprspec[:ignorecase] @text_colors = exprspec[:text_colors] @wholelines = exprspec[:whole_lines] @wholewords = exprspec[:whole_words] end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
15 16 17 |
# File 'lib/glark/match/re_factory.rb', line 15 def count @count end |
Instance Method Details
#create_expression(pattern, negated = false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/glark/match/re_factory.rb', line 27 def create_expression pattern, negated = false # this check is because they may have omitted the pattern, e.g.: # % glark *.cpp if File.exists? pattern warn "pattern '#{pattern}' exists as a file.\n Pattern may have been omitted." end regex = Regexp.create(pattern.dup, :negated => negated, :ignorecase => @ignorecase, :wholewords => @wholewords, :wholelines => @wholelines, :extended => @extended) re = RegexpExpression.new regex, @count, @text_colors, @extract_matches @count += 1 re end |