Class: Buhos::CriteriaProcessor
- Inherits:
-
Object
- Object
- Buhos::CriteriaProcessor
- Defined in:
- lib/buhos/criteria_processor.rb
Overview
Provide action to process Inclusion vs Exclusion criteria
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
-
#initialize(sr) ⇒ CriteriaProcessor
constructor
A new instance of CriteriaProcessor.
- #process_array(param_array, type) ⇒ Object
- #update_criteria(inclusion, exclusion) ⇒ Object
Constructor Details
#initialize(sr) ⇒ CriteriaProcessor
Returns a new instance of CriteriaProcessor.
34 35 36 37 |
# File 'lib/buhos/criteria_processor.rb', line 34 def initialize(sr) @sr=sr @error=false end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
33 34 35 |
# File 'lib/buhos/criteria_processor.rb', line 33 def error @error end |
Instance Method Details
#process_array(param_array, type) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/buhos/criteria_processor.rb', line 50 def process_array(param_array, type) previous_ids=SrCriterion.where(:criteria_type=>type.to_s, :systematic_review_id=>@sr.id).select_map(:criterion_id) new_ids=[] param_array.each do |text| crit=Criterion.get_criterion(text.chomp) new_ids.push(crit[:id]) SrCriterion.sr_criterion_add(@sr,crit, type) end to_delete=previous_ids-new_ids to_delete.each do |criterion_id| SrCriterion.sr_criterion_remove(@sr, Criterion[criterion_id]) end end |
#update_criteria(inclusion, exclusion) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/buhos/criteria_processor.rb', line 38 def update_criteria(inclusion, exclusion) # Criteria already defined inclusion||=[] exclusion||=[] inclusion=inclusion.map {|v| v.to_s.chomp}.delete_if {|v| v==""} exclusion=exclusion.map {|v| v.to_s.chomp}.delete_if {|v| v==""} process_array(inclusion, 'inclusion') process_array(exclusion, 'exclusion') end |