Sha256: 48bfe225c00eedc7e77740ee1235864f04e4d6579a6cda65235bd79285074194

Contents?: true

Size: 664 Bytes

Versions: 4

Compression:

Stored size: 664 Bytes

Contents

require_relative '../command_handler'
require_relative 'models/g_color'

module Glimmer
  class ColorCommandHandler
    include CommandHandler

    include_package 'org.eclipse.swt.widgets'

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

    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 = nil
      end
      GColor.new(display, *args)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glimmer-0.4.3 lib/glimmer/command_handlers/color_command_handler.rb
glimmer-0.4.2 lib/glimmer/command_handlers/color_command_handler.rb
glimmer-0.4.1 lib/glimmer/command_handlers/color_command_handler.rb
glimmer-0.4.0 lib/glimmer/command_handlers/color_command_handler.rb