class Tk::Variable
This class is used for communication of variables with Tcl.
Attributes
bytesize[R]
name[R]
tcl_name[R]
Public Class Methods
new(name, value = None)
click to toggle source
# File lib/ffi-tk/variable.rb, line 9 def initialize(name, value = None) @name = name.freeze @tcl_name = "$#{name}" set(value) unless None == value end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/ffi-tk/variable.rb, line 59 def <=>(other) case other when self.class get <=> other.get else get <=> other end end
get()
click to toggle source
# File lib/ffi-tk/variable.rb, line 15 def get Tk.execute('set', name) rescue RuntimeError raise NameError, "can't read %p: no such variable" % [name] end
set(value)
click to toggle source
# File lib/ffi-tk/variable.rb, line 21 def set(value) Tk.execute_only('set', name, value) end
to_boolean()
click to toggle source
# File lib/ffi-tk/variable.rb, line 41 def to_boolean got = get if got.respond_to?(:to_boolean) got.to_boolean elsif got == '0' false elsif got == '1' true else got end end
to_f()
click to toggle source
# File lib/ffi-tk/variable.rb, line 55 def to_f get.to_f end
to_i()
click to toggle source
# File lib/ffi-tk/variable.rb, line 37 def to_i get.to_i end
to_s()
click to toggle source
# File lib/ffi-tk/variable.rb, line 33 def to_s get.to_s end
to_tcl()
click to toggle source
# File lib/ffi-tk/variable.rb, line 29 def to_tcl TclString.new(name) end
unset()
click to toggle source
# File lib/ffi-tk/variable.rb, line 25 def unset Tk.execute_only('unset', name) end