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

[Source]

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

[Source]

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

[Source]

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

[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

[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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]