Module: Tk::CoreExtensions::Array

Defined in:
lib/ffi-tk/core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#tcl_options_to_hash(hints = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ffi-tk/core_extensions.rb', line 17

def tcl_options_to_hash(hints = {})
  ::Hash[each_slice(2).map{|key, value|
    key = key.sub(/^-/, '').to_sym

    case hint = hints[key]
    when :boolean
      [key, Tk.boolean(value)]
    when :symbol
      [key, value.to_sym]
    when :float
      [key, Float(value)]
    else
      [key, value]
    end
  }]
end

#to_tclObject



13
14
15
# File 'lib/ffi-tk/core_extensions.rb', line 13

def to_tcl
  TclString.new('{' << map(&:to_tcl).compact.join(' ') << '}')
end