Class: GithubDailyDigest::OutputFormatter
- Inherits:
-
Object
- Object
- GithubDailyDigest::OutputFormatter
- Defined in:
- lib/output_formatter.rb
Instance Method Summary collapse
- #format(results, format_type = nil) ⇒ Object
-
#initialize(config:, logger:) ⇒ OutputFormatter
constructor
A new instance of OutputFormatter.
Constructor Details
#initialize(config:, logger:) ⇒ OutputFormatter
Returns a new instance of OutputFormatter.
3 4 5 6 |
# File 'lib/output_formatter.rb', line 3 def initialize(config:, logger:) @config = config @logger = logger end |
Instance Method Details
#format(results, format_type = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/output_formatter.rb', line 8 def format(results, format_type = nil) # If a specific format_type is provided, use that # Otherwise, use the first format from the config output_format = format_type || (@config.output_formats&.first || 'json') case output_format when 'json' format_as_json(results) when 'markdown' format_as_markdown(results) when 'html' # HTML formatting is handled by HtmlFormatter but we need to recognize it as valid format_as_json(results) # Return JSON data that HtmlFormatter will use else @logger.warn("Unknown output format: #{output_format}, defaulting to JSON") format_as_json(results) end end |