Module: CC::Service::QualityHelper
- Included in:
- Slack
- Defined in:
- lib/cc/helpers/quality_helper.rb
Instance Method Summary collapse
- #constant_basename(name) ⇒ Object
- #constant_name ⇒ Object
- #improved? ⇒ Boolean
- #previous_rating ⇒ Object
- #previous_remediation_cost ⇒ Object
- #rating ⇒ Object
- #remediation_cost ⇒ Object
- #with_article(letter, bold = false) ⇒ Object
Instance Method Details
#constant_basename(name) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/cc/helpers/quality_helper.rb', line 37 def constant_basename(name) if name.include?(".") File.basename(name) else name end end |
#constant_name ⇒ Object
6 7 8 |
# File 'lib/cc/helpers/quality_helper.rb', line 6 def constant_name payload["constant_name"] end |
#improved? ⇒ Boolean
2 3 4 |
# File 'lib/cc/helpers/quality_helper.rb', line 2 def improved? remediation_cost < previous_remediation_cost end |
#previous_rating ⇒ Object
14 15 16 |
# File 'lib/cc/helpers/quality_helper.rb', line 14 def with_article(payload["previous_rating"]) end |
#previous_remediation_cost ⇒ Object
22 23 24 |
# File 'lib/cc/helpers/quality_helper.rb', line 22 def previous_remediation_cost payload.fetch("previous_remediation_cost", 0) end |
#rating ⇒ Object
10 11 12 |
# File 'lib/cc/helpers/quality_helper.rb', line 10 def with_article(payload["rating"]) end |
#remediation_cost ⇒ Object
18 19 20 |
# File 'lib/cc/helpers/quality_helper.rb', line 18 def remediation_cost payload.fetch("remediation_cost", 0) end |
#with_article(letter, bold = false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cc/helpers/quality_helper.rb', line 26 def with_article(letter, bold = false) letter ||= '?' text = bold ? "*#{letter}*" : letter if %w( A F ).include?(letter.to_s) "an #{text}" else "a #{text}" end end |