Sha256: 157c51e00cf9170c60a16fcd7728b6dcaaaae314f3f72832eed59153df221e78
Contents?: true
Size: 628 Bytes
Versions: 5
Compression:
Stored size: 628 Bytes
Contents
$LOAD_PATH.unshift '../lib' require 'memory_record' class Palette include MemoryRecord memory_record [ { key: :coral, r: 255, g: 127, b: 0 }, { key: :tomato, r: 255, g: 99, b: 71 }, { key: :gold, r: 255, g: 215, b: 0 }, ] def rgb [r, g, b] end def hex "#" + rgb.collect { |e| "%02X" % e }.join end def name super.capitalize end end Palette[:tomato].key # => :tomato Palette[:tomato].name # => "Tomato" Palette[:tomato].rgb # => [255, 99, 71] Palette[:tomato].hex # => "#FF6347" Palette.collect(&:hex) # => ["#FF7F00", "#FF6347", "#FFD700"]
Version data entries
5 entries across 5 versions & 1 rubygems