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.



27
28
29
30
31
32
# File 'lib/imagga/image.rb', line 27

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



23
24
25
# File 'lib/imagga/image.rb', line 23

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

.fieldsObject



19
20
21
# File 'lib/imagga/image.rb', line 19

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



34
35
36
# File 'lib/imagga/image.rb', line 34

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



40
41
42
# File 'lib/imagga/image.rb', line 40

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