Class: BrandLogo::Strategies::Scraping::DimensionsExtractor

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/brand_logo/strategies/scraping/dimensions_extractor.rb

Overview

Extracts pixel dimensions from a favicon link element. Tries the HTML ‘sizes` attribute first (no network), then falls back to the injected ImageAnalyzer (may make a network request).

Instance Method Summary collapse

Constructor Details

#initialize(image_analyzer:) ⇒ DimensionsExtractor

Returns a new instance of DimensionsExtractor.



16
17
18
# File 'lib/brand_logo/strategies/scraping/dimensions_extractor.rb', line 16

def initialize(image_analyzer:)
  @image_analyzer = T.let(image_analyzer, ImageAnalyzer)
end

Instance Method Details

#extract(link, href) ⇒ Object



22
23
24
# File 'lib/brand_logo/strategies/scraping/dimensions_extractor.rb', line 22

def extract(link, href)
  extract_from_sizes_attribute(link) || @image_analyzer.dimensions(href)
end