Class: Coloractor

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

Defined Under Namespace

Classes: Palette

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Coloractor



11
12
13
14
# File 'lib/coloractor.rb', line 11

def initialize(filename)
  @filename        = filename
  @dominant_colors = []
end

Instance Attribute Details

#background_colorObject (readonly)

Returns the value of attribute background_color.



9
10
11
# File 'lib/coloractor.rb', line 9

def background_color
  @background_color
end

#dominant_colorsObject (readonly)

Returns the value of attribute dominant_colors.



9
10
11
# File 'lib/coloractor.rb', line 9

def dominant_colors
  @dominant_colors
end

Class Method Details

.extract_colors(filename) ⇒ Object



3
4
5
6
7
# File 'lib/coloractor.rb', line 3

def self.extract_colors(filename)
  new(filename).tap do |instance|
    instance.extract_colors
  end
end

Instance Method Details

#extract_colorsObject



16
17
18
19
20
21
# File 'lib/coloractor.rb', line 16

def extract_colors
  palette = Coloractor::Palette.build_from_file(@filename)

  @dominant_colors  = palette.colors
  @background_color = palette.background_color
end