Sha256: d29d8b0838d51ee2b5fe18e1a8829658060814bfb14c4fb00264f23d75d5b7da

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

module Glimmer
  class GSWT
    class << self
      java_import 'org.eclipse.swt.SWT'

      # Gets SWT constants as if calling SWT::CONSTANT where constant is
      # passed in as a lower case symbol
      def [](*symbols)
        symbols.compact.reduce(0) { |output, symbol| output | constant(symbol) }
      end

      def constant(symbol)
        return symbol if symbol.is_a?(Integer)
        swt_constant_symbol = symbol.to_s.upcase.to_sym
        SWT.const_get(swt_constant_symbol)
      rescue
        swt_constant_symbol = SWT.constants.find {|c| c.to_s.upcase == swt_constant_symbol.to_s}
        SWT.const_get(swt_constant_symbol)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glimmer-0.4.0 lib/glimmer/command_handlers/models/g_swt.rb