Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > tk/variableライブラリ > TkVariableクラス

class TkVariable

クラスの継承リスト: TkVariable < Tk < TkCore < TkComm < TkUtil < TkEvent < Comparable < Object < Kernel < BasicObject
extend: TkCore

要約

Tclの変数をアクセスするためのクラスです。 ((-Tclの配列としての振る舞いは仕様が不安定のようです-))

require "tk"
p TkVariable.new(0).value                     # => "0"
p TkVariable.new(1.2).value                   # => "1.2"
p TkVariable.new(["a", "b"]).value            # => {"0"=>"a", "1"=>"b"}
p TkVariable.new(1=>"a", 2=>"b").value        # => {"1"=>"a", "2"=>"b"}

特異メソッド

定義 説明
callback(args)

TkVariable#traceにより登録されたProcオブジェクトを実行します。 args は、 [TkVariableのインスタンス, "キー", "操作"] である配列です。

new(val="")

値がvalであるTkVariableオブジェクトを生成します。valが Array または Hash のオブジェクトである場合、生成されたインス タンスは Tclの配列として振る舞います。

new_hash(val = {})

インスタンスメソッド

定義 説明
self % other
self & other
self * other
self ** other
self + other
self - other
self / other
self <=> other
self == other

値がotherと同じである場合に真です。otherは、 TkVariable, String, Integer, Float, Arrayのいずれかです。

self =~ other
self[index]

index番目の値を返します。 selfはTclの配列でなければなりません。

self[index] = val

index番目の要素をvalにします。 selfはTclの配列でなければなりません。

bool
bool=
set_bool
bool_element
bool_type=
set_bool_type(val)
clear
coerce(other)
default_element_value_type(idxs)
default_proc(cmd = Proc.new)
default_value(val = nil)
default_value(val = nil) { .... }
default_value=
default_value_type
default_value_type=
set_default_value_type(type)
element_lappend(idxs, *elems)
element_lindex(elem_idxs, idx)
element_lget(elem_idxs, idx)
element_lget_f(elem_idxs, idx)
element_lget_i(elem_idxs, idx)
element_lset(elem_idxs, idx, val)
list_element(*idxs)
element_to_a(*idxs)
element_to_f(*idxs)
element_to_i(*idxs)
element_to_s(*idxs)
string_element(*idxs)
element_to_sym(*idxs)
eventloop_tkwait
eventloop_wait(check_root = false)
exist?(*elems)
id
is_hash?
is_scalar?
keys
lappend(*elems)
lindex(idx)
lget(idx)
lget_f(idx)
lget_i(idx)
list
list=
list_type=
set_list_type(val)
lset(idx, val)
nonzero?
numeric
numeric=
numeric_element(*idxs)
set_numeric_type(val)
numeric_type=
numlist
set_numlist(val)
numlist=
numlist_element(*idxs)
set_numlist_type(val)
numlist_type=
procedure
set_procedure(cmd)
procedure=
procedure_element(*idxs)
procedure_type=
set_procedure_type(cmd)
ref(*idxs)
unset(elem=nil)
remove(elem=nil)

値がTcl配列であるとき、elemの値を削除します。

set_bool_element
set_bool_element_type(idxs, val)
set_default_element_value_type(idxs, type)
set_default_value(val)
set_element_value(idxs, val)
set_element_value_type(idxs, val)
set_list(val)
set_list_element(idxs, val)
set_numlist_element(idxs, val)
set_list_element_type(idxs, val)
set_numeric(val)
set_numeric_element(idxs, val)
set_numeric_element_type(idxs, val)
set_numlist_element_type(idxs, val)
set_procedure_element(idxs, cmd)
set_procedure_element_type(idxs, cmd)
string=
set_string(val)
set_string_element(idxs, val)
set_string_element_type(idxs, val)
string_type=
set_string_type(val)
symbol=
set_symbol(val)
set_symbol_element(idxs, val)
set_symbol_element_type(idxs, val)
symbol_type=
set_symbol_type(val)
set_value(val)

値を val に設定し、self を返します。

set_value_type(val)
value_type=
set_variable(var)
variable=
set_variable_element(*idxs)
set_variable_element_type(idxs, var)
set_variable_type(var)
variable_type=
set_window(win)
window=
set_window_element(idxs, win)
set_window_element_type(idxs, win)
set_window_type(win)
window_type=
size
string
symbol
to_sym
symbol_element
thread_tkwait
thread_wait(check_root = false)
tkwait(on_thread = true)
to_a

値を配列(Array)として返します。

to_eval
to_f

値を数値(Float)として返します。

to_i

値を数値(Fixnum)として返します。(現状のTkVariableは、 Bignumを値にすることはできません)

to_s

値を文字列(String)として返します。

trace(opts, cmd)

optsは、"r", "w", "u" のいずれか、またはこれらの組み合わせで、それぞれ 変数が参照、設定、削除 されたときにProcオブジェクト cmd を 呼び出します。2回目以降の呼び出しでは、opts が以前の設定と異なれ ばcmdを再設定します。

trace_callback(elem, op)

TkVariable#traceにより登録されたProcオブジェクトを引数にself, elem, opを指定して実行します。

trace_element(elem, opts, cmd)
trace_vdelete(opts, cmd)

TkVariable#trace で設定したcmdを削除します。opts が TkVariable#trace で 設定したときと一致しなければ何もしません。

trace_vdelete_for_element(elem, opts, cmd)
trace_vinfo
undef_default
update(hash)
value

値を返します。selfがTclの配列ならば(Tclの配列は連想配列な ので) Hashとして返します。それ以外では常に文字列を返します。

value=(val)

値をvalに設定します。

variable
variable_element(*idxs)
wait

値が変化するまで待ちます。

window
window_element(*idxs)
zero?
self | other

定数

定義 説明
TkCommandNames
TkVar_CB_TBL

コールバック関数を記録するハッシュです。内部で利用しています。

TkVar_ID_TBL
Tk_VARIABLE_ID

Tclレベルの変数名をインスタンスに割り当てるために内部で利用されています。

USE_TCLs_SET_VARIABLE_FUNCTIONS

継承したメソッド

! != < <= > >= between? === __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods must_be must_be_close_to must_be_empty must_be_instance_of must_be_kind_of must_be_nil must_be_same_as must_be_within_epsilon must_equal must_include must_match must_raise must_respond_to must_send must_throw nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? respond_to_missing? singleton_class singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_ary to_hash to_int to_io to_proc to_regexp to_str to_yaml to_yaml_properties to_yaml_style trust untaint untrust untrusted? wont_be wont_be_close_to wont_be_empty wont_be_instance_of wont_be_kind_of wont_be_nil wont_be_same_as wont_be_within_epsilon wont_equal wont_include wont_match wont_respond_to root ::AUTO_PATH ::JAPANIZED_TK ::LIBRARY_PATH ::PACKAGE_PATH ::TCL_LIBRARY_PATH ::TCL_MAJOR_VERSION ::TCL_MINOR_VERSION ::TCL_PACKAGE_PATH ::TCL_PATCHLEVEL ::TCL_PRECISION ::TCL_VERSION ::TK_MAJOR_VERSION ::TK_MINOR_VERSION ::TK_PATCHLEVEL ::TK_VERSION ::Tkextlib_RELEASE_DATE bind bind_all bind_append bind_append_all bind_remove bind_remove_all bindinfo bindinfo_all subst ::GET_CONFIGINFO_AS_ARRAY ::GET_CONFIGINFOwoRES_AS_ARRAY ::TkExtlibAutoloadModule ::Tk_CMDTBL ::Tk_IDs ::Tk_WINDOWS ::USE_TCLs_LIST_FUNCTIONS ::WidgetClassNames _tk_call_to_list_core after after_cancel after_idle appname appsend appsend_deny appsend_displayof callback_break callback_continue callback_return chooseColor chooseDirectory do_one_event event_generate getMultipleOpenFile getMultipleSaveFile getOpenFile getSaveFile get_eventloop_tick get_eventloop_weight get_no_event_wait inactive inactive_displayof info ip_eval ip_eval_with_enc ip_eval_without_enc ip_invoke ip_invoke_with_enc ip_invoke_without_enc is_mainloop? load_cmd_on_ip mainloop mainloop_exist? mainloop_thread? mainloop_watchdog messageBox rb_appsend rb_appsend_displayof reset_inactive reset_inactive_displayof restart scaling scaling_displayof set_eventloop_ticktimer_tick set_eventloop_weight set_no_event_wait tk_call tk_call_to_list tk_call_to_list_with_enc tk_call_to_list_without_enc tk_call_to_simplelist tk_call_to_simplelist_with_enc tk_call_to_simplelist_without_enc tk_call_with_enc tk_call_without_enc windowingsystem ::EventFlag ::INTERP ::WIDGET_DESTROY_HOOK install_bind install_bind_for_event_class _conv_args _fromUTF8 _get_eval_enc_str _get_eval_string _symbolkey2str _toUTF8 bool hash_kv num_or_str number string ::None ::RELEASE_DATE