Class: Qa::MeshTree
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Qa::MeshTree
- Defined in:
- app/models/qa/mesh_tree.rb
Class Method Summary collapse
Instance Method Summary collapse
- #classify_tree ⇒ Object
- #classify_tree! ⇒ Object
- #eval_tree_path ⇒ Object
-
#lookup_tree_term(tree_id) ⇒ Object
given a tree id, return the main subject term e.g.
Class Method Details
.classify_all_trees ⇒ Object
4 5 6 7 8 |
# File 'app/models/qa/mesh_tree.rb', line 4 def self.classify_all_trees MeshTreeStructure.find_each do |mts| mts.classify_tree! end end |
Instance Method Details
#classify_tree ⇒ Object
19 20 21 22 |
# File 'app/models/qa/mesh_tree.rb', line 19 def classify_tree tree_levels = initial_segements_of(tree_structure) tree_levels.map &method(:lookup_tree_term) end |
#classify_tree! ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/qa/mesh_tree.rb', line 24 def classify_tree! unless classify_tree.empty? tree_path = classify_tree.join('|') puts "After Join #{tree_path.inspect}" update_attribute(:eval_tree_path, tree_path) end end |
#eval_tree_path ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/models/qa/mesh_tree.rb', line 10 def eval_tree_path trees = read_attribute(:eval_tree_path) || write_attribute(:eval_tree_path, "") if trees trees.split("|") else [] end end |
#lookup_tree_term(tree_id) ⇒ Object
given a tree id, return the main subject term e.g. ‘C03.752.530’ returns ‘Malaria’
34 35 36 |
# File 'app/models/qa/mesh_tree.rb', line 34 def lookup_tree_term(tree_id) self.class.get_term(tree_id).first.term end |