Class: RSwing::Components::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/rswing/components/options.rb

Class Method Summary collapse

Class Method Details

.gui_optionsObject

Hash of all valid default-values for rswing options.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rswing/components/options.rb', line 24

def self.gui_options
  {
    :enabled => true,
    :visible => true,
    :editable => true,
    :resizable => true,
    :modal => true,
    :double_buffer => true,
    :dialog_type => :info,
    :option_type => :yes_no,
    :option_values => ["Yes", "No"],
    :option_default_title => "Please select:",
    :icon => nil,
    :belongs_to => nil,
    :layout => nil,
    :layout_manager => nil,
    :title => nil,
    :name => nil,
    :font => nil,
    :doc => nil,
    :size => nil,
    :location => nil,
    :columns => 10,
    :text => "",
    :selected => false
  }
end

.value_for(hash) ⇒ Object

Returns the value of a key (which is given as the value of the hash). If the value to the key isn’t given in the hash, return the default-value from gui_options-hash.

  • Example:

    <tt>Options.value_for(options => :name)</tt>
    


57
58
59
60
61
62
63
64
# File 'lib/rswing/components/options.rb', line 57

def self.value_for(hash)
  raise "Value must be a hash!" unless hash.kind_of? Hash
  hash.each_pair do |options_hash, option_key|
    # it should only be one pair specified,
    # so we can simply take the first and return the appropriate value
    return options_hash[option_key].nil? ? gui_options[option_key] : options_hash[option_key]
  end
end