Class: Imagga::ImageInfo

Inherits:
ImageInfoBase show all
Defined in:
lib/imagga/image.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ImageInfo

Returns a new instance of ImageInfo.



29
30
31
32
33
34
# File 'lib/imagga/image.rb', line 29

def initialize(opts={})
  super(opts['info'].merge('url' => opts['url']))
  self.class.color_fields.each do |field|
    send("#{field}=", build_image_colors(opts['info'][field]))
  end
end

Class Method Details

.color_fieldsObject



25
26
27
# File 'lib/imagga/image.rb', line 25

def self.color_fields
  %w(image_colors foreground_colors background_colors)
end

.fieldsObject



21
22
23
# File 'lib/imagga/image.rb', line 21

def self.fields
  %w(url object_percentage color_variance image_packed foreground_packed background_packed)
end

Instance Method Details

#build_image_colors(image_color_nodes) ⇒ Object



36
37
38
# File 'lib/imagga/image.rb', line 36

def build_image_colors(image_color_nodes)
  image_color_nodes && image_color_nodes.map { |color_node| ImageColor.new(color_node) }
end

#color_variance=(value) ⇒ Object



42
43
44
# File 'lib/imagga/image.rb', line 42

def color_variance=(value)
  @color_variance = value.to_i
end