Class: Newshound::WarningReporter
- Inherits:
-
Object
- Object
- Newshound::WarningReporter
- Defined in:
- lib/newshound/warning_reporter.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#time_range ⇒ Object
readonly
Returns the value of attribute time_range.
-
#warning_source ⇒ Object
readonly
Returns the value of attribute warning_source.
Instance Method Summary collapse
-
#banner_data ⇒ Object
Returns data formatted for the banner UI.
- #generate_report ⇒ Object (also: #report)
-
#initialize(warning_source: nil, configuration: nil, time_range: 24.hours) ⇒ WarningReporter
constructor
A new instance of WarningReporter.
Constructor Details
#initialize(warning_source: nil, configuration: nil, time_range: 24.hours) ⇒ WarningReporter
Returns a new instance of WarningReporter.
7 8 9 10 11 |
# File 'lib/newshound/warning_reporter.rb', line 7 def initialize(warning_source: nil, configuration: nil, time_range: 24.hours) @configuration = configuration || Newshound.configuration @warning_source = resolve_warning_source(warning_source) @time_range = time_range end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/newshound/warning_reporter.rb', line 5 def configuration @configuration end |
#time_range ⇒ Object (readonly)
Returns the value of attribute time_range.
5 6 7 |
# File 'lib/newshound/warning_reporter.rb', line 5 def time_range @time_range end |
#warning_source ⇒ Object (readonly)
Returns the value of attribute warning_source.
5 6 7 |
# File 'lib/newshound/warning_reporter.rb', line 5 def warning_source @warning_source end |
Instance Method Details
#banner_data ⇒ Object
Returns data formatted for the banner UI
30 31 32 33 34 35 36 |
# File 'lib/newshound/warning_reporter.rb', line 30 def return {warnings: []} unless warning_source { warnings: recent_warnings.map { |warning| warning_source.(warning) } } end |
#generate_report ⇒ Object Also known as: report
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/newshound/warning_reporter.rb', line 13 def generate_report return no_warnings_block if recent_warnings.empty? [ { type: "section", text: { type: "mrkdwn", text: "*⚠️ Recent Warnings (Last 24 Hours)*" } }, *format_warnings ] end |