Sha256: d0854fda9e6f8a31a0ec72720a63237b32b6f356f72d6d9c1c29c151af465d4c
Contents?: true
Size: 444 Bytes
Versions: 4
Compression:
Stored size: 444 Bytes
Contents
# frozen_string_literal: true module RGB Color = Micro::Struct.with(:readonly, :to_ary).new(:red, :green, :blue) do def initialize(r, g, b) super( Number.new(value: r, label: 'red'), Number.new(value: g, label: 'green'), Number.new(value: b, label: 'blue') ) end def to_a @to_a ||= super.map(&:value) end def to_hex @to_hex ||= "##{red}#{green}#{blue}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
u-struct-1.1.0 | examples/rgb/color.rb |
u-struct-1.0.0 | examples/rgb/color.rb |
u-struct-0.12.0 | examples/rgb/color.rb |
u-struct-0.11.0 | examples/rgb/color.rb |