Class: BrandLogo::Strategies::BaseStrategy
- Inherits:
-
Object
- Object
- BrandLogo::Strategies::BaseStrategy
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/brand_logo/strategies/base_strategy.rb
Overview
Abstract base class implementing the Template Method pattern.
Subclasses implement ‘fetch_all` (the customization point). `fetch` is the common algorithm: fetch_all → filter valid → select best. This eliminates duplicated selection/validation logic across strategies.
Direct Known Subclasses
DuckduckgoStrategy, ManifestStrategy, MetaTagStrategy, ScrapingStrategy
Constant Summary collapse
- UNKNOWN_DIMENSION_SCORE =
T.let(-1, Integer)
Instance Method Summary collapse
- #fetch(domain) ⇒ Object
- #fetch_all(domain) ⇒ Object
-
#initialize(config:) ⇒ BaseStrategy
constructor
A new instance of BaseStrategy.
Constructor Details
#initialize(config:) ⇒ BaseStrategy
Returns a new instance of BaseStrategy.
22 23 24 |
# File 'lib/brand_logo/strategies/base_strategy.rb', line 22 def initialize(config:) @config = T.let(config, Config) end |
Instance Method Details
#fetch(domain) ⇒ Object
34 35 36 37 |
# File 'lib/brand_logo/strategies/base_strategy.rb', line 34 def fetch(domain) valid_icons = fetch_all(domain).select { |icon| valid_icon?(icon) } select_best_icon(valid_icons) end |
#fetch_all(domain) ⇒ Object
29 |
# File 'lib/brand_logo/strategies/base_strategy.rb', line 29 def fetch_all(domain); end |