Class: Glimmer::SWT::CommandHandlers::ColorCommandHandler

Inherits:
Object
  • Object
show all
Includes:
CommandHandler
Defined in:
lib/glimmer/swt/command_handlers/color_command_handler.rb

Instance Method Summary collapse

Instance Method Details

#can_handle?(parent, command_symbol, *args, &block) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/glimmer/swt/command_handlers/color_command_handler.rb', line 12

def can_handle?(parent, command_symbol, *args, &block)
  ['rgba', 'rgb'].include?(command_symbol.to_s) and
  (3..5).include?(args.count)
end

#do_handle(parent, command_symbol, *args, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/glimmer/swt/command_handlers/color_command_handler.rb', line 17

def do_handle(parent, command_symbol, *args, &block)
  if args.first.is_a?(Display) || args.first.nil?
    display = args.delete_at(0)
  elsif parent.is_a?(GWidget)
    display = parent.widget.display
  else
    display = GDisplay.instance.display
  end
  GColor.new(display, *args)
end