class ASEPalette::Group
Attributes
colors[R]
Name and colors cannot changed once a group is created in order to protect the integrity of unique names in a palette
name[R]
Name and colors cannot changed once a group is created in order to protect the integrity of unique names in a palette
Public Class Methods
new(name)
click to toggle source
Initialize group
# File lib/ase-palette/group.rb, line 8 def initialize(name) @name = name @colors = [] end
Public Instance Methods
remove_color_with_name(name)
click to toggle source
# File lib/ase-palette/group.rb, line 35 def remove_color_with_name(name) @colors = @colors.select { |color| color.name != name } end
to_h()
click to toggle source
Convert group to hash, necessary for binary representation
# File lib/ase-palette/group.rb, line 28 def to_h { name: @name, colors: @colors.map(&:to_h), } end
to_s()
click to toggle source
Convert group to string
# File lib/ase-palette/group.rb, line 14 def to_s s = "- #{@name}:\n" if @colors.length > 0 @colors.each do |color| s += " #{color}\n" end else s += " <empty>\n" end s end