Class: ImageOptim::ImageMeta

Inherits:
Object
  • Object
show all
Defined in:
lib/image_optim/image_meta.rb

Overview

Getting format of image at path or as data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format) ⇒ ImageMeta

Returns a new instance of ImageMeta.



21
22
23
# File 'lib/image_optim/image_meta.rb', line 21

def initialize(format)
  @format = format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



20
21
22
# File 'lib/image_optim/image_meta.rb', line 20

def format
  @format
end

Class Method Details

.for_data(data) ⇒ Object



13
14
15
16
17
18
# File 'lib/image_optim/image_meta.rb', line 13

def self.for_data(data)
  is = ImageSize.new(data)
  new(is.format)
rescue ImageSize::FormatError => e
  warn "#{e} (detecting format of image data)"
end

.for_path(path) ⇒ Object



6
7
8
9
10
11
# File 'lib/image_optim/image_meta.rb', line 6

def self.for_path(path)
  is = ImageSize.path(path)
  new(is.format)
rescue ImageSize::FormatError => e
  warn "#{e} (detecting format of image at #{path})"
end