Class: RSwt

Inherits:
Object
  • Object
show all
Defined in:
lib/command_handlers/models/r_swt.rb

Class Method Summary collapse

Class Method Details

.[](*symbols) ⇒ Object

Gets SWT constants as if calling SWT::CONSTANT where constant is passed in as a lower case symbol



5
6
7
# File 'lib/command_handlers/models/r_swt.rb', line 5

def [](*symbols)
  symbols.compact.reduce(0) { |output, symbol| output | constant(symbol) }
end

.constant(symbol) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/command_handlers/models/r_swt.rb', line 9

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