Module: Iup::AttributeReference

Included in:
Dialog, ImageAttributes, ProgressDialog, Tabs
Defined in:
lib/wrapped/attribute-reference.rb

Overview

Defines method for getting/setting attribute values.

Instance Method Summary collapse

Instance Method Details

#attribute_reference(name, target, val = nil) ⇒ Object

Method used to get or set the value of attributes.

when retrieving

simply return the attribute with given name.

when setting

an attribute reference can be defined by its string name or directly as an instance of target class



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wrapped/attribute-reference.rb', line 10

def attribute_reference name, target, val=nil
  case val
  when NilClass
    IupLib.IupGetAttribute(@handle, name).first
  when String
    IupLib.IupSetAttribute @handle, name, val
  when target
    image_name = IupLib.IupGetName(name).first
    if image_name.nil? or image_name.empty?
      image_name = SecureRandom.uuid 
      val.assign_handle image_name
    end
    IupLib.IupSetAttribute @handle, name, image_name
  end
end