Class: Tcl::Var

Inherits:
Object
  • Object
show all
Includes:
InterpHelper
Defined in:
lib/tcl/var.rb

Direct Known Subclasses

ArrayVar, StringVar

Constant Summary collapse

BUILTINS =
%w(
  auto_index auto_oldpath auto_path env errorCode errorInfo
  tcl_libPath tcl_library tcl_patchLevel tcl_pkgPath tcl_platform tcl_version
)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InterpHelper

#_, #_!, included, #method_missing

Constructor Details

#initialize(interp, name) ⇒ Var

Returns a new instance of Var.



24
25
26
27
28
# File 'lib/tcl/var.rb', line 24

def initialize(interp, name)
  @interp = interp
  @name = name.to_s
  to_tcl
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tcl::InterpHelper

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/tcl/var.rb', line 22

def name
  @name
end

Class Method Details

.find(interp, name) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/tcl/var.rb', line 11

def find(interp, name)
  if interp._!(:array, :exists, name) == "1"
    ArrayVar.new(interp, name)
  elsif interp._!(:info, :exists, name) == "1"
    StringVar.new(interp, name)
  else
    raise Tcl::Error, "can't read \"#{name}\": no such variable"
  end
end

Instance Method Details

#builtin?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/tcl/var.rb', line 30

def builtin?
  BUILTINS.include?(name)
end