Class: FastExists::Intelligence::Doctor
- Inherits:
-
Object
- Object
- FastExists::Intelligence::Doctor
- Defined in:
- lib/fast_exists/intelligence/doctor.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(analysis, audit, health) ⇒ Doctor
constructor
A new instance of Doctor.
- #render(format = :console) ⇒ Object
Constructor Details
#initialize(analysis, audit, health) ⇒ Doctor
Returns a new instance of Doctor.
15 16 17 18 19 |
# File 'lib/fast_exists/intelligence/doctor.rb', line 15 def initialize(analysis, audit, health) @analysis = analysis @audit = audit @health = health end |
Class Method Details
.diagnose(format = :console) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fast_exists/intelligence/doctor.rb', line 6 def self.diagnose(format = :console) fmt = format.is_a?(Hash) ? (format[:format] || :console) : format analysis = FastExists::Intelligence::Analyzer.analyze audit = FastExists::Intelligence::Auditor.audit health = FastExists::Intelligence::Health.check new(analysis, audit, health).render(format: fmt) end |
Instance Method Details
#render(format = :console) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fast_exists/intelligence/doctor.rb', line 21 def render(format = :console) fmt = format.is_a?(Hash) ? (format[:format] || :console) : format recommendations = build_recommendations case fmt.to_sym when :json JSON.pretty_generate(recommendations) when :yaml recommendations.transform_keys(&:to_s).to_yaml when :markdown to_markdown(recommendations) when :html to_html(recommendations) else to_console(recommendations) end end |