module Tk::CoreExtensions::Array
Public Instance Methods
tcl_options_to_hash(hints = {})
click to toggle source
try to convert to a Hash
. it may return an Array
if this contains none.
# File lib/ffi-tk/core_extensions.rb, line 20 def tcl_options_to_hash(hints = {}) if first.respond_to?(:to_ary) hash = {} each do |key, _, _, _, value| next if !value || (value.respond_to?(:empty?) && value.empty?) key = key.sub(/^-/, '').to_sym hash[key] = case hint = hints[key] when :boolean Tk.boolean(value) when :symbol value.to_sym when :float Float(value) else value end end hash elsif first =~ /^-/ ::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 }] else self end end
to_tcl()
click to toggle source
# File lib/ffi-tk/core_extensions.rb, line 14 def to_tcl TclString.new("{#{map(&:to_tcl).compact.join(' ')}}") end