Sha256: 1053f43c741c49cdf0f1426f82d996a88f3cbf2038e3343813b635835b7ec264

Contents?: true

Size: 564 Bytes

Versions: 1

Compression:

Stored size: 564 Bytes

Contents

ColorCategory = Struct.new(:name, :colors)

Color = Struct.new(:name, :code) do
  def name_with_code
    "#{name} (#{code})"
  end

  def self.all
    [
      new("Red", "#f00"),
      new("Green", "#0f0"),
      new("Blue", "#00f")
    ]
  end

  def self.categorized
    [
      ColorCategory.new("Primary", [
        new("Red", "#f00"),
        new("Green", "#0f0"),
        new("Blue", "#00f")
      ]),

      ColorCategory.new("Secondary", [
        new("Yellow", "#ff0"),
        new("Magenta", "#f0f"),
        new("Cyan", "#0ff")
      ])
    ]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trestle-0.8.0 sandbox/app/models/color.rb