class Gdk::RGBA

Public Class Methods

new(red=nil, green=nil, blue=nil, alpha=nil) click to toggle source
# File lib/gdk3/rgba.rb, line 52
def initialize(red=nil, green=nil, blue=nil, alpha=nil)
  initialize_raw
  self.red = red if red
  self.green = green if green
  self.blue = blue if blue
  self.alpha = alpha || 1.0
end
Also aliased as: initialize_raw
parse(spec) click to toggle source
# File lib/gdk3/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
try_convert(value) click to toggle source
# File lib/gdk3/rgba.rb, line 39
def try_convert(value)
  case value
  when String
    parse(value)
  when Symbol
    parse(value.to_s)
  else
    nil
  end
end

Public Instance Methods

initialize_raw(red=nil, green=nil, blue=nil, alpha=nil)
Alias for: new
to_a() click to toggle source
# File lib/gdk3/rgba.rb, line 60
def to_a
  [red, green, blue, alpha]
end