Class: Lorax::MatchSet

Inherits:
Object
  • Object
show all
Defined in:
lib/lorax/match_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc1, doc2, dependency_injection = {}) ⇒ MatchSet

Returns a new instance of MatchSet.



5
6
7
8
9
10
11
# File 'lib/lorax/match_set.rb', line 5

def initialize(doc1, doc2, dependency_injection={})
  @document1  = doc1
  @document2  = doc2
  @signature1 = dependency_injection[:match_set_signature1] || Lorax::Signature.new(@document1.root)
  @signature2 = dependency_injection[:match_set_signature2] || Lorax::Signature.new(@document2.root)
  @matches    = {}
end

Instance Attribute Details

#signature1Object

Returns the value of attribute signature1.



3
4
5
# File 'lib/lorax/match_set.rb', line 3

def signature1
  @signature1
end

#signature2Object

Returns the value of attribute signature2.



3
4
5
# File 'lib/lorax/match_set.rb', line 3

def signature2
  @signature2
end

Instance Method Details

#add(match) ⇒ Object



22
23
24
# File 'lib/lorax/match_set.rb', line 22

def add(match)
  match.pair.each { |node| @matches[node] = match }
end

#match(node) ⇒ Object



13
14
15
# File 'lib/lorax/match_set.rb', line 13

def match(node)
  @matches[node]
end

#matchesObject



17
18
19
20
# File 'lib/lorax/match_set.rb', line 17

def matches
  puts "MIKE: #{__FILE__}:#{__LINE__} REMOVE ME THIS IS FOR DEBUGGING ONLY"
  @matches.values.uniq.collect {|m| [m.pair.first.path, m.pair.last.path, m.perfect?]}.sort
end

#to_delta_setObject



26
27
28
# File 'lib/lorax/match_set.rb', line 26

def to_delta_set
  DeltaSetGenerator.generate_delta_set(self)
end