Class Tk::BLT::Vector
In: tkextlib/blt/vector.rb
Parent: TkVariable

Methods

*   +   -   /   []   []=   append   binread   clear   create   delete   destroy   destroy   dup_vector   expr   expr   index   inspect   length   length=   merge   names   new   normalize   notify   offset   offset=   populate   random   range   search   seq   set   sort   sort_reverse   split   to_s   variable  

Constants

TkCommandNames = ['::blt::vector'.freeze].freeze

Public Class methods

[Source]

    # File tkextlib/blt/vector.rb, line 13
13:     def self.create(*args)
14:       tk_call('::blt::vector', 'create', *args)
15:     end

[Source]

    # File tkextlib/blt/vector.rb, line 17
17:     def self.destroy(*args)
18:       tk_call('::blt::vector', 'destroy', *args)
19:     end

[Source]

    # File tkextlib/blt/vector.rb, line 21
21:     def self.expr(expression)
22:       tk_call('::blt::vector', 'expr', expression)
23:     end

[Source]

    # 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

[Source]

    # 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

[Source]

    # File tkextlib/blt/vector.rb, line 81
81:     def *(item)
82:       list(tk_call(@id, '*', item))
83:     end

[Source]

    # File tkextlib/blt/vector.rb, line 85
85:     def +(item)
86:       list(tk_call(@id, '+', item))
87:     end

[Source]

    # File tkextlib/blt/vector.rb, line 89
89:     def -(item)
90:       list(tk_call(@id, '-', item))
91:     end

[Source]

    # File tkextlib/blt/vector.rb, line 93
93:     def /(item)
94:       list(tk_call(@id, '/', item))
95:     end

[Source]

     # File tkextlib/blt/vector.rb, line 135
135:     def [](idx)
136:       index(idx)
137:     end

[Source]

     # File tkextlib/blt/vector.rb, line 139
139:     def []=(idx, val)
140:       index(idx, val)
141:     end

[Source]

    # File tkextlib/blt/vector.rb, line 97
97:     def append(*vectors)
98:       tk_call(@id, 'append', *vectors)
99:     end

[Source]

     # 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

[Source]

     # File tkextlib/blt/vector.rb, line 111
111:     def clear()
112:       tk_call(@id, 'clear')
113:       self
114:     end

[Source]

     # File tkextlib/blt/vector.rb, line 116
116:     def delete(*indices)
117:       tk_call(@id, 'delete', *indices)
118:       self
119:     end

[Source]

    # File tkextlib/blt/vector.rb, line 69
69:     def destroy
70:       tk_call('::blt::vector', 'destroy', @id)
71:     end

[Source]

     # File tkextlib/blt/vector.rb, line 121
121:     def dup_vector(vec)
122:       tk_call(@id, 'dup', vec)
123:       self
124:     end

[Source]

     # File tkextlib/blt/vector.rb, line 126
126:     def expr(expression)
127:       tk_call(@id, 'expr', expression)
128:       self
129:     end

[Source]

     # File tkextlib/blt/vector.rb, line 131
131:     def index(idx, val=None)
132:       number(tk_call(@id, 'index', idx, val))
133:     end

[Source]

    # File tkextlib/blt/vector.rb, line 73
73:     def inspect
74:       '#<Tk::BLT::Vector: ' + @id + '>'
75:     end

[Source]

     # File tkextlib/blt/vector.rb, line 143
143:     def length()
144:       number(tk_call(@id, 'length'))
145:     end

[Source]

     # File tkextlib/blt/vector.rb, line 147
147:     def length=(size)
148:       number(tk_call(@id, 'length', size))
149:     end

[Source]

     # File tkextlib/blt/vector.rb, line 151
151:     def merge(*vectors)
152:       tk_call(@id, 'merge', *vectors)
153:       self
154:     end

[Source]

     # File tkextlib/blt/vector.rb, line 156
156:     def normalize(vec=None)
157:       tk_call(@id, 'normalize', vec)
158:       self
159:     end

[Source]

     # File tkextlib/blt/vector.rb, line 161
161:     def notify(keyword)
162:       tk_call(@id, 'notify', keyword)
163:       self
164:     end

[Source]

     # File tkextlib/blt/vector.rb, line 166
166:     def offset()
167:       number(tk_call(@id, 'offset'))
168:     end

[Source]

     # File tkextlib/blt/vector.rb, line 170
170:     def offset=(val)
171:       number(tk_call(@id, 'offset', val))
172:     end

[Source]

     # File tkextlib/blt/vector.rb, line 178
178:     def populate(vector, density=None)
179:       tk_call(@id, 'populate', vector, density)
180:       self
181:     end

[Source]

     # File tkextlib/blt/vector.rb, line 174
174:     def random()
175:       tk_call(@id, 'random')
176:     end

[Source]

     # File tkextlib/blt/vector.rb, line 183
183:     def range(first, last=None)
184:       list(tk_call(@id, 'range', first, last))
185:     end

[Source]

     # File tkextlib/blt/vector.rb, line 187
187:     def search(val1, val2=None)
188:       list(tk_call(@id, 'search', val1, val2))
189:     end

[Source]

     # 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

[Source]

     # File tkextlib/blt/vector.rb, line 191
191:     def set(item)
192:       tk_call(@id, 'set', item)
193:       self
194:     end

[Source]

     # File tkextlib/blt/vector.rb, line 201
201:     def sort(*vectors)
202:       tk_call(@id, 'sort', *vectors)
203:       self
204:     end

[Source]

     # File tkextlib/blt/vector.rb, line 206
206:     def sort_reverse(*vectors)
207:       tk_call(@id, 'sort', '-reverse', *vectors)
208:       self
209:     end

[Source]

     # File tkextlib/blt/vector.rb, line 211
211:     def split(*vectors)
212:       tk_call(@id, 'split', *vectors)
213:       self
214:     end

[Source]

    # File tkextlib/blt/vector.rb, line 77
77:     def to_s
78:       @id
79:     end

[Source]

     # File tkextlib/blt/vector.rb, line 216
216:     def variable(var)
217:       tk_call(@id, 'variable', var)
218:       self
219:     end

Search

Google

Ruby API Docs

Links