Class: EmbeddableContent::Images::ImageDownloader

Inherits:
Object
  • Object
show all
Defined in:
app/services/embeddable_content/images/image_downloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attached_image) ⇒ ImageDownloader

Returns a new instance of ImageDownloader.



8
9
10
# File 'app/services/embeddable_content/images/image_downloader.rb', line 8

def initialize(attached_image)
  @attached_image = attached_image
end

Instance Attribute Details

#attached_imageObject (readonly)

Returns the value of attribute attached_image.



4
5
6
# File 'app/services/embeddable_content/images/image_downloader.rb', line 4

def attached_image
  @attached_image
end

Instance Method Details

#deleteObject



16
17
18
# File 'app/services/embeddable_content/images/image_downloader.rb', line 16

def delete
  image_file.delete if image_file.exist?
end

#raw_svgObject



20
21
22
# File 'app/services/embeddable_content/images/image_downloader.rb', line 20

def raw_svg
  @raw_svg ||= downloaded_image_data if svg_attached?
end

#saveObject



12
13
14
# File 'app/services/embeddable_content/images/image_downloader.rb', line 12

def save
  image_file.tap { |file| file.write raw_image_data }
end