Module: Glimmer::SWT::Properties

Included in:
Custom::Animation, Custom::Shape, ImageProxy, ProxyProperties
Defined in:
lib/glimmer/swt/properties.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attribute_getter(attribute_name) ⇒ Object



36
37
38
39
# File 'lib/glimmer/swt/properties.rb', line 36

def attribute_getter(attribute_name)
  @attribute_getters ||= {}
  @attribute_getters[attribute_name] ||= "get#{normalized_attribute(attribute_name).camelcase(:upper)}"
end

.attribute_setter(attribute_name) ⇒ Object



31
32
33
34
# File 'lib/glimmer/swt/properties.rb', line 31

def attribute_setter(attribute_name)
  @attribute_setters ||= {}
  @attribute_setters[attribute_name] ||= "set#{normalized_attribute(attribute_name).camelcase(:upper)}"
end

.normalized_attribute(attribute_name) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/glimmer/swt/properties.rb', line 41

def normalized_attribute(attribute_name)
  @normalized_attributes ||= {}
  if @normalized_attributes[attribute_name].nil?
    attribute_name = attribute_name.to_s if attribute_name.is_a?(Symbol)
    attribute_name = attribute_name.underscore unless attribute_name.downcase?
    attribute_name = attribute_name.sub(/^get_/, '') if attribute_name.start_with?('get_')
    attribute_name = attribute_name.sub(/^set_/, '') if attribute_name.start_with?('set_')
    attribute_name = attribute_name.sub(/=$/, '') if attribute_name.end_with?('=')
    @normalized_attributes[attribute_name] = attribute_name
  end
  @normalized_attributes[attribute_name]
end

.ruby_attribute_getterObject



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/glimmer/swt/properties.rb', line 53

def normalized_attribute(attribute_name)
  @normalized_attributes ||= {}
  if @normalized_attributes[attribute_name].nil?
    attribute_name = attribute_name.to_s if attribute_name.is_a?(Symbol)
    attribute_name = attribute_name.underscore unless attribute_name.downcase?
    attribute_name = attribute_name.sub(/^get_/, '') if attribute_name.start_with?('get_')
    attribute_name = attribute_name.sub(/^set_/, '') if attribute_name.start_with?('set_')
    attribute_name = attribute_name.sub(/=$/, '') if attribute_name.end_with?('=')
    @normalized_attributes[attribute_name] = attribute_name
  end
  @normalized_attributes[attribute_name]
end

.ruby_attribute_setter(attribute_name) ⇒ Object



26
27
28
29
# File 'lib/glimmer/swt/properties.rb', line 26

def ruby_attribute_setter(attribute_name)
  @ruby_attribute_setters ||= {}
  @ruby_attribute_setters[attribute_name] ||= "#{normalized_attribute(attribute_name)}="
end

Instance Method Details

#attribute_getter(attribute_name) ⇒ Object



64
65
66
# File 'lib/glimmer/swt/properties.rb', line 64

def attribute_getter(attribute_name)
  Glimmer::SWT::Properties.attribute_getter(attribute_name)
end

#attribute_setter(attribute_name) ⇒ Object



60
61
62
# File 'lib/glimmer/swt/properties.rb', line 60

def attribute_setter(attribute_name)
  Glimmer::SWT::Properties.attribute_setter(attribute_name)
end

#normalized_attribute(attribute_name) ⇒ Object Also known as: ruby_attribute_getter



68
69
70
# File 'lib/glimmer/swt/properties.rb', line 68

def normalized_attribute(attribute_name)
  Glimmer::SWT::Properties.normalized_attribute(attribute_name)
end

#ruby_attribute_setter(attribute_name) ⇒ Object



56
57
58
# File 'lib/glimmer/swt/properties.rb', line 56

def ruby_attribute_setter(attribute_name)
  Glimmer::SWT::Properties.ruby_attribute_setter(attribute_name)
end