Sha256: 384b09bcafd115db00e3bedb30cb95cbd9e7ff0f49430cdccec64daa09c21b85

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

# frozen_string_literal: true

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'u-struct', path: '..'
  gem 'kind'
end

require_relative 'rgb/number'
require_relative 'rgb/color'

rgb_color = RGB::Color.new(r: 1, g: 1, b: 255)

p rgb_color

puts
puts format('to_hex: %p', rgb_color.to_hex)
puts format('to_a: %p', rgb_color.to_a)
puts

r, g, b = rgb_color

puts format('red: %p', r)
puts format('green: %p', g)
puts format('blue: %p', b)

RGB::Color.new(r: 1, g: -1, b: 255) # Kind::Error (g: -1 expected to be a kind of Integer(>= 0 and <= 255))

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
u-struct-0.10.0 examples/rgb_3.rb
u-struct-0.9.0 examples/rgb_3.rb