Method: Concept#try_adding_references

Defined in:
lib/asker/data/concept.rb

#try_adding_references(other) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/asker/data/concept.rb', line 91

def try_adding_references(other)
  reference_to = 0
  @data[:tags].each do |i|
    reference_to += 1 unless other.names.index(i.downcase).nil?
  end
  @data[:texts].each do |t|
    text = t.clone
    text.split(" ").each do |word|
      reference_to += 1 unless other.names.index(word.downcase).nil?
    end
  end
  return unless reference_to.positive?

  @data[:reference_to] << other.name
  other.data[:referenced_by] << name
end