Class: Tk::Variable
Overview
This class is used for communication of variables with Tcl.
Instance Attribute Summary collapse
-
#bytesize ⇒ Object
readonly
Returns the value of attribute bytesize.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tcl_name ⇒ Object
readonly
Returns the value of attribute tcl_name.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(name, value = None) ⇒ Variable
constructor
A new instance of Variable.
- #set(value) ⇒ Object
- #to_boolean ⇒ Object
- #to_f ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
- #to_tcl ⇒ Object
- #unset ⇒ Object
Constructor Details
Instance Attribute Details
#bytesize ⇒ Object (readonly)
Returns the value of attribute bytesize.
4 5 6 |
# File 'lib/ffi-tk/variable.rb', line 4 def bytesize @bytesize end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/ffi-tk/variable.rb', line 4 def name @name end |
#tcl_name ⇒ Object (readonly)
Returns the value of attribute tcl_name.
4 5 6 |
# File 'lib/ffi-tk/variable.rb', line 4 def tcl_name @tcl_name end |
Instance Method Details
#get ⇒ Object
12 13 14 15 16 |
# File 'lib/ffi-tk/variable.rb', line 12 def get Tk.execute('set', name) rescue RuntimeError raise NameError, "can't read %p: no such variable" % [name] end |
#set(value) ⇒ Object
18 19 20 |
# File 'lib/ffi-tk/variable.rb', line 18 def set(value) Tk.execute_only('set', name, value) end |
#to_boolean ⇒ Object
38 39 40 |
# File 'lib/ffi-tk/variable.rb', line 38 def to_boolean get.to_boolean end |
#to_f ⇒ Object
42 43 44 |
# File 'lib/ffi-tk/variable.rb', line 42 def to_f get.to_f end |
#to_i ⇒ Object
34 35 36 |
# File 'lib/ffi-tk/variable.rb', line 34 def to_i get.to_i end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/ffi-tk/variable.rb', line 30 def to_s get.to_s end |
#to_tcl ⇒ Object
26 27 28 |
# File 'lib/ffi-tk/variable.rb', line 26 def to_tcl TclString.new(name) end |
#unset ⇒ Object
22 23 24 |
# File 'lib/ffi-tk/variable.rb', line 22 def unset Tk.execute_only('unset', name) end |