| Class | Tk::BLT::Vector |
| In: |
tkextlib/blt/vector.rb
|
| Parent: | TkVariable |
Constants
| TkCommandNames | = | ['::blt::vector'.freeze].freeze |
Public Class methods
# File tkextlib/blt/vector.rb, line 13
13: def self.create(*args)
14: tk_call('::blt::vector', 'create', *args)
15: end
# File tkextlib/blt/vector.rb, line 17
17: def self.destroy(*args)
18: tk_call('::blt::vector', 'destroy', *args)
19: end
# File tkextlib/blt/vector.rb, line 21
21: def self.expr(expression)
22: tk_call('::blt::vector', 'expr', expression)
23: end
# File tkextlib/blt/vector.rb, line 25
25: def self.names(pat=None)
26: simplelist(tk_call('::blt::vector', 'names', pat)).collect{|name|
27: if TkVar_ID_TBL[name]
28: TkVar_ID_TBL[name]
29: elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
30: TkVar_ID_TBL[name[2..-1]]
31: else
32: name
33: end
34: }
35: end
# File tkextlib/blt/vector.rb, line 39
39: def initialize(size=nil, keys={})
40: if size.kind_of?(Hash)
41: keys = size
42: size = nil
43: end
44: if size.kind_of?(Array)
45: # [first, last]
46: size = size.join(':')
47: end
48: if size
49: @id = INTERP._invoke('::blt::vector', 'create',
50: "#auto(#{size})", *hash_kv(keys))
51: else
52: @id = INTERP._invoke('::blt::vector', 'create',
53: "#auto", *hash_kv(keys))
54: end
55:
56: TkVar_ID_TBL[@id] = self
57:
58: @def_default = false
59: @default_val = nil
60:
61: @trace_var = nil
62: @trace_elem = nil
63: @trace_opts = nil
64:
65: # teach Tk-ip that @id is global var
66: INTERP._invoke_without_enc('global', @id)
67: end
Public Instance methods
# File tkextlib/blt/vector.rb, line 97
97: def append(*vectors)
98: tk_call(@id, 'append', *vectors)
99: end
# File tkextlib/blt/vector.rb, line 101
101: def binread(channel, len=None, keys={})
102: if len.kind_of?(Hash)
103: keys = len
104: len = None
105: end
106: keys = _symbolkey2str(keys)
107: keys['swap'] = None if keys.delete('swap')
108: tk_call(@id, 'binread', channel, len, keys)
109: end
# File tkextlib/blt/vector.rb, line 111
111: def clear()
112: tk_call(@id, 'clear')
113: self
114: end
# File tkextlib/blt/vector.rb, line 116
116: def delete(*indices)
117: tk_call(@id, 'delete', *indices)
118: self
119: end
# File tkextlib/blt/vector.rb, line 69
69: def destroy
70: tk_call('::blt::vector', 'destroy', @id)
71: end
# File tkextlib/blt/vector.rb, line 121
121: def dup_vector(vec)
122: tk_call(@id, 'dup', vec)
123: self
124: end
# File tkextlib/blt/vector.rb, line 126
126: def expr(expression)
127: tk_call(@id, 'expr', expression)
128: self
129: end
# File tkextlib/blt/vector.rb, line 131
131: def index(idx, val=None)
132: number(tk_call(@id, 'index', idx, val))
133: end
# File tkextlib/blt/vector.rb, line 73
73: def inspect
74: '#<Tk::BLT::Vector: ' + @id + '>'
75: end
# File tkextlib/blt/vector.rb, line 143
143: def length()
144: number(tk_call(@id, 'length'))
145: end
# File tkextlib/blt/vector.rb, line 147
147: def length=(size)
148: number(tk_call(@id, 'length', size))
149: end
# File tkextlib/blt/vector.rb, line 151
151: def merge(*vectors)
152: tk_call(@id, 'merge', *vectors)
153: self
154: end
# File tkextlib/blt/vector.rb, line 156
156: def normalize(vec=None)
157: tk_call(@id, 'normalize', vec)
158: self
159: end
# File tkextlib/blt/vector.rb, line 161
161: def notify(keyword)
162: tk_call(@id, 'notify', keyword)
163: self
164: end
# File tkextlib/blt/vector.rb, line 166
166: def offset()
167: number(tk_call(@id, 'offset'))
168: end
# File tkextlib/blt/vector.rb, line 170
170: def offset=(val)
171: number(tk_call(@id, 'offset', val))
172: end
# File tkextlib/blt/vector.rb, line 178
178: def populate(vector, density=None)
179: tk_call(@id, 'populate', vector, density)
180: self
181: end
# File tkextlib/blt/vector.rb, line 183
183: def range(first, last=None)
184: list(tk_call(@id, 'range', first, last))
185: end
# File tkextlib/blt/vector.rb, line 187
187: def search(val1, val2=None)
188: list(tk_call(@id, 'search', val1, val2))
189: end
# File tkextlib/blt/vector.rb, line 196
196: def seq(start, finish=None, step=None)
197: tk_call(@id, 'seq', start, finish, step)
198: self
199: end
# File tkextlib/blt/vector.rb, line 191
191: def set(item)
192: tk_call(@id, 'set', item)
193: self
194: end
# File tkextlib/blt/vector.rb, line 201
201: def sort(*vectors)
202: tk_call(@id, 'sort', *vectors)
203: self
204: end
# File tkextlib/blt/vector.rb, line 206
206: def sort_reverse(*vectors)
207: tk_call(@id, 'sort', '-reverse', *vectors)
208: self
209: end
# File tkextlib/blt/vector.rb, line 211
211: def split(*vectors)
212: tk_call(@id, 'split', *vectors)
213: self
214: end