Method: Gdk::RGBA.parse

Defined in:
lib/gdk4/rgba.rb

.parse(spec) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gdk4/rgba.rb', line 20

def parse(spec)
  rgba = new
  unless rgba.parse(spec)
    available_formats = [
      "COLOR_NAME",
      "\#RGB",
      "\#RRGGBB",
      "\#RRRGGGBBB",
      "\#RRRRGGGGBBBB",
      "rgb(R, G, B)",
      "rgba(R, G, B, A)",
    ]
    message = "invalid RGBA format: #{spec.inspect} "
    message << "(available formats: #{available_formats.join(', ')})"
    raise ArgumentError, message
  end
  rgba
end