Class: ColorCommandHandler

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

Instance Method Summary collapse

Instance Method Details

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



9
10
11
12
# File 'lib/command_handlers/color_command_handler.rb', line 9

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



14
15
16
17
18
19
20
21
22
23
# File 'lib/command_handlers/color_command_handler.rb', line 14

def do_handle(parent, command_symbol, *args, &block)
  if args.first.is_a?(Display)
    display = args.delete_at(0)
  elsif parent.is_a?(RWidget)
    display = parent.widget.display
  else
    display = nil
  end
  RColor.new(display, *args)
end