Class: Html2rss::FeedPipeline::AutoFallback::AttemptState
- Inherits:
-
Object
- Object
- Html2rss::FeedPipeline::AutoFallback::AttemptState
- Defined in:
- lib/html2rss/feed_pipeline/auto_fallback.rb
Overview
Mutable run state for one auto-fallback chain: attempts plus selected result.
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize ⇒ AttemptState
constructor
A new instance of AttemptState.
- #record_error(strategy:, error:) ⇒ void
- #record_items(strategy:, items_count:, transport_meta: nil) ⇒ void
- #remember_response(response) ⇒ void
- #succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:) ⇒ void
-
#succeeded? ⇒ Boolean
True when a strategy already yielded items.
Constructor Details
#initialize ⇒ AttemptState
Returns a new instance of AttemptState.
30 31 32 33 34 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 30 def initialize @attempts = [] @result = nil @last_response = nil end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
28 29 30 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 28 def attempts @attempts end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
28 29 30 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 28 def last_response @last_response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
28 29 30 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 28 def result @result end |
Instance Method Details
#record_error(strategy:, error:) ⇒ void
This method returns an undefined value.
42 43 44 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 42 def record_error(strategy:, error:) @attempts << { strategy:, items_count: nil, error_class: error.class.name } end |
#record_items(strategy:, items_count:, transport_meta: nil) ⇒ void
This method returns an undefined value.
50 51 52 53 54 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 50 def record_items(strategy:, items_count:, transport_meta: nil) attempt = { strategy:, items_count:, error_class: nil } attempt[:transport_meta] = if && !.empty? @attempts << attempt end |
#remember_response(response) ⇒ void
This method returns an undefined value.
58 59 60 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 58 def remember_response(response) @last_response = response end |
#succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:) ⇒ void
This method returns an undefined value.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 68 def succeed!(response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:) @result = PipelineOutcome.new( response:, articles:, dedup_dropped:, selected_strategy:, attempt_count:, strategy_attempts: attempts ) end |
#succeeded? ⇒ Boolean
Returns true when a strategy already yielded items.
37 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 37 def succeeded? = !result.nil? |