Class: VitalsImage::Analyzer::UrlAnalyzer

Inherits:
VitalsImage::Analyzer show all
Defined in:
lib/vitals_image/analyzer/url_analyzer.rb

Instance Attribute Summary

Attributes inherited from VitalsImage::Analyzer

#source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VitalsImage::Analyzer

#initialize, #logger

Constructor Details

This class inherits a constructor from VitalsImage::Analyzer

Class Method Details

.accept?(source) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/vitals_image/analyzer/url_analyzer.rb', line 7

def self.accept?(source)
  source.is_a?(Source)
end

Instance Method Details

#analyzeObject



11
12
13
14
15
16
17
# File 'lib/vitals_image/analyzer/url_analyzer.rb', line 11

def analyze
  file = download
  image = open(file)
  mime  = Marcel::MimeType.for(Pathname.new file.path)

  source.update width: image.width, height: image.height, analyzed: true, content_type: mime
end