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 |
# File 'app/models/qa/mesh_tree.rb', line 4 def self.classify_all_trees MeshTreeStructure.find_each(&:classify_tree!) end |
Instance Method Details
#classify_tree ⇒ Object
17 18 19 20 |
# File 'app/models/qa/mesh_tree.rb', line 17 def classify_tree tree_levels = initial_segements_of(tree_structure) tree_levels.map(&:lookup_tree_term) end |
#classify_tree! ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/models/qa/mesh_tree.rb', line 22 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
8 9 10 11 12 13 14 15 |
# File 'app/models/qa/mesh_tree.rb', line 8 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’
32 33 34 |
# File 'app/models/qa/mesh_tree.rb', line 32 def lookup_tree_term(tree_id) self.class.get_term(tree_id).first.term end |