Class: FuzzyMatch::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzzy_match/rule.rb,
lib/fuzzy_match/rule/grouping.rb,
lib/fuzzy_match/rule/identity.rb

Overview

A rule characterized by a regexp. Abstract.

Direct Known Subclasses

Grouping, Identity

Defined Under Namespace

Classes: Grouping, Identity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp) ⇒ Rule

Returns a new instance of Rule.



6
7
8
9
10
11
# File 'lib/fuzzy_match/rule.rb', line 6

def initialize(regexp)
  unless regexp.is_a?(::Regexp)
    raise ArgumentError, "[FuzzyMatch] Rules must be set with Regexp objects, but got #{regexp.inspect} (#{regexp.class.name})"
  end
  @regexp = regexp
end

Instance Attribute Details

#regexpObject (readonly)

Returns the value of attribute regexp.



4
5
6
# File 'lib/fuzzy_match/rule.rb', line 4

def regexp
  @regexp
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/fuzzy_match/rule.rb', line 13

def ==(other)
  other.class == self.class and regexp == other.regexp
end