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.
-
#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:) ⇒ void
- #succeed!(response:, articles:) ⇒ void
-
#succeeded? ⇒ Boolean
True when a strategy already yielded items.
Constructor Details
#initialize ⇒ AttemptState
Returns a new instance of AttemptState.
30 31 32 33 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 30 def initialize @attempts = [] @result = 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 |
#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.
41 42 43 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 41 def record_error(strategy:, error:) @attempts << { strategy:, items_count: nil, error_class: error.class.name } end |
#record_items(strategy:, items_count:) ⇒ void
This method returns an undefined value.
48 49 50 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 48 def record_items(strategy:, items_count:) @attempts << { strategy:, items_count:, error_class: nil } end |
#succeed!(response:, articles:) ⇒ void
This method returns an undefined value.
55 56 57 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 55 def succeed!(response:, articles:) @result = { response:, articles: } end |
#succeeded? ⇒ Boolean
Returns true when a strategy already yielded items.
36 |
# File 'lib/html2rss/feed_pipeline/auto_fallback.rb', line 36 def succeeded? = !result.nil? |