Class: Gdk::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/gdk3/color.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(red, green, blue) ⇒ Color

Returns a new instance of Color.



49
50
51
52
53
54
# File 'lib/gdk3/color.rb', line 49

def initialize(red, green, blue)
  initialize_raw
  self.red = red
  self.green = green
  self.blue = blue
end

Class Method Details

.parse(spec) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gdk3/color.rb', line 21

def parse(spec)
  succeeded, color = parse_raw(spec)
  unless succeeded
    message = "Invalid color spec: <#{spec.inspect}>: "
    message << "Color spec must be one of them: "
    message << "\"\#rgb\", "
    message << "\"\#rrggbb\", "
    message << "\"\#rrggbb\", "
    message << "\"\#rrrgggbbb\", "
    message << "\"\#rrrrggggbbbb\""
    raise ArgumentError, message
  end
  color
end

.parse_rawObject



20
# File 'lib/gdk3/color.rb', line 20

alias_method :parse_raw, :parse

.try_convert(value) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/gdk3/color.rb', line 36

def try_convert(value)
  case value
  when String
    parse(value)
  when Symbol
    parse(value.to_s)
  else
    nil
  end
end

Instance Method Details

#initialize_rawObject



48
# File 'lib/gdk3/color.rb', line 48

alias_method :initialize_raw, :initialize