Class: Array

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

Instance Method Summary collapse

Instance Method Details

#mappings(array2) ⇒ Object

Returns an array of hashes with the possible mappings between the elements in both arrays



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lightrdf.rb', line 28

def mappings array2
  return [{}] if self.empty? or array2.empty?
  mappings = []
  each do |item|
    mapping = {}
    array2.each do |item2|
      mapping[item] = item2
      (self - [item]).mappings(array2 - [item2]).each do |submapping|
        mappings << mapping.merge(submapping)
      end
    end
  end
  mappings.uniq
end