Class | Tk::BLT::Vector
In: | tk/lib/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

create(*args)

[Source]

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

destroy(*args)

[Source]

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

expr(expression)

[Source]

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

names(pat=None)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 25
        def self.names(pat=None)
          simplelist(tk_call('::blt::vector', 'names', pat)).collect{|name|
            if TkVar_ID_TBL[name]
              TkVar_ID_TBL[name]
            elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
              TkVar_ID_TBL[name[2..-1]]
            else
              name
            end
          }
        end

new(size=nil, keys={})

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 39
        def initialize(size=nil, keys={})
          if size.kind_of?(Hash)
            keys = size
            size = nil
          end
          if size.kind_of?(Array)
            # [first, last]
            size = size.join(':')
          end
          if size
            @id = INTERP._invoke('::blt::vector', 'create',
                                 "#auto(#{size})", *hash_kv(keys))
          else
            @id = INTERP._invoke('::blt::vector', 'create',
                                 "#auto", *hash_kv(keys))
          end

          TkVar_ID_TBL[@id] = self

          @def_default = false
          @default_val = nil

          @trace_var  = nil
          @trace_elem = nil
          @trace_opts = nil

          # teach Tk-ip that @id is global var
          INTERP._invoke_without_enc('global', @id)
        end

### Public Instance methods

*(item)

[Source]

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

+(item)

[Source]

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

-(item)

[Source]

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

/(item)

[Source]

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

[](idx)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 135
        def [](idx)
          index(idx)
        end

[]=(idx, val)

[Source]

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

append(*vectors)

[Source]

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

binread(channel, len=None, keys={})

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 101
        def binread(channel, len=None, keys={})
          if len.kind_of?(Hash)
            keys = len
            len = None
          end
          keys = _symbolkey2str(keys)
          keys['swap'] = None if keys.delete('swap')
          tk_call(@id, 'binread', channel, len, keys)
        end

clear()

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 111
        def clear()
          tk_call(@id, 'clear')
          self
        end

delete(*indices)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 116
        def delete(*indices)
          tk_call(@id, 'delete', *indices)
          self
        end

destroy()

[Source]

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

dup_vector(vec)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 121
        def dup_vector(vec)
          tk_call(@id, 'dup', vec)
          self
        end

expr(expression)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 126
        def expr(expression)
          tk_call(@id, 'expr', expression)
          self
        end

index(idx, val=None)

[Source]

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

inspect()

[Source]

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

length()

[Source]

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

length=(size)

[Source]

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

merge(*vectors)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 151
        def merge(*vectors)
          tk_call(@id, 'merge', *vectors)
          self
        end

normalize(vec=None)

[Source]

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

notify(keyword)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 161
        def notify(keyword)
          tk_call(@id, 'notify', keyword)
          self
        end

offset()

[Source]

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

offset=(val)

[Source]

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

populate(vector, density=None)

[Source]

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

random()

[Source]

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

range(first, last=None)

[Source]

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

search(val1, val2=None)

[Source]

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

seq(start, finish=None, step=None)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 196
        def seq(start, finish=None, step=None)
          tk_call(@id, 'seq', start, finish, step)
          self
        end

set(item)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 191
        def set(item)
          tk_call(@id, 'set', item)
          self
        end

sort(*vectors)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 201
        def sort(*vectors)
          tk_call(@id, 'sort', *vectors)
          self
        end

sort_reverse(*vectors)

[Source]

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

split(*vectors)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 211
        def split(*vectors)
          tk_call(@id, 'split', *vectors)
          self
        end

to_s()

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 77
        def to_s
          @id
        end

variable(var)

[Source]

    # File tk/lib/tkextlib/blt/vector.rb, line 216
        def variable(var)
          tk_call(@id, 'variable', var)
          self
        end

[Validate]