class Samantha::Palette
Attributes
colors[RW]
Public Class Methods
new()
click to toggle source
# File lib/palette.rb, line 6 def initialize @colors = [] end
Public Instance Methods
add_color(hex)
click to toggle source
# File lib/palette.rb, line 10 def add_color(hex) existing_color = @colors.detect { |c| c.hex == hex } existing_color ? existing_color.tally : @colors.push(Color.new(hex.downcase)) end
sort_colors()
click to toggle source
# File lib/palette.rb, line 15 def sort_colors @colors.sort_by! { |c| c.count }.reverse! end