Module: CompletenessFu::ActiveRecordAdditions::InstanceMethods
- Defined in:
- lib/completeness-fu/active_record_additions.rb
Instance Method Summary collapse
-
#completeness_grade ⇒ Object
returns a basic ‘grading’ based on percent_complete, defaults are :high, :medium, :low, and :poor.
-
#completeness_score ⇒ Object
returns the absolute complete score.
-
#failed_checks ⇒ Object
returns an array of hashes with the translated name, description + weighting.
-
#passed_checks ⇒ Object
returns an array of hashes with the translated name, description + weighting.
-
#percent_complete ⇒ Object
returns the percentage of completeness (relative score).
Instance Method Details
#completeness_grade ⇒ Object
returns a basic ‘grading’ based on percent_complete, defaults are :high, :medium, :low, and :poor
66 67 68 69 70 71 |
# File 'lib/completeness-fu/active_record_additions.rb', line 66 def completeness_grade CompletenessFu.default_gradings.each do |grading| return grading.first if grading.last.include?(self.percent_complete.round) end raise CompletenessFuError, "grade could not be determined with percent complete #{self.percent_complete.round}" end |
#completeness_score ⇒ Object
returns the absolute complete score
54 55 56 57 58 |
# File 'lib/completeness-fu/active_record_additions.rb', line 54 def completeness_score sum_score = 0 passed_checks.each { |check| sum_score += check[:weighting] } sum_score end |
#failed_checks ⇒ Object
returns an array of hashes with the translated name, description + weighting
44 45 46 |
# File 'lib/completeness-fu/active_record_additions.rb', line 44 def failed_checks all_checks_which_pass(false) end |
#passed_checks ⇒ Object
returns an array of hashes with the translated name, description + weighting
49 50 51 |
# File 'lib/completeness-fu/active_record_additions.rb', line 49 def passed_checks all_checks_which_pass end |
#percent_complete ⇒ Object
returns the percentage of completeness (relative score)
61 62 63 |
# File 'lib/completeness-fu/active_record_additions.rb', line 61 def percent_complete self.completeness_score.to_f / self.class.max_completeness_score.to_f * 100 end |