Class: Tcl::Interp

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InterpHelper

#_, #_!, included, #method_missing

Dynamic Method Handling

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

Class Method Details

.load_from_file(filename) ⇒ Object



6
7
8
9
10
# File 'lib/tcl/interp.rb', line 6

def load_from_file(filename)
  interp = new
  interp.eval(IO.read(filename))
  interp
end

Instance Method Details

#expose(name) ⇒ Object



21
22
23
# File 'lib/tcl/interp.rb', line 21

def expose(name)
  _!(:interp, :alias, nil, name, nil, :interp_send, name)
end

#interpObject



13
14
15
# File 'lib/tcl/interp.rb', line 13

def interp
  self
end

#interp_receive(method, *args) ⇒ Object



17
18
19
# File 'lib/tcl/interp.rb', line 17

def interp_receive(method, *args)
  send("tcl_#{method}", *args)
end

#proc(name) ⇒ Object



25
26
27
# File 'lib/tcl/interp.rb', line 25

def proc(name)
  Tcl::Proc.new(self, name)
end

#procsObject



33
34
35
# File 'lib/tcl/interp.rb', line 33

def procs
  list_to_array _!(:info, :procs)
end

#to_tclObject



41
42
43
44
45
46
47
48
49
# File 'lib/tcl/interp.rb', line 41

def to_tcl
  %w( var proc ).inject([]) do |lines, type|
    send("#{type}s").sort.each do |name|
      object = send(type, name)
      lines << object.to_tcl unless object.builtin?
    end
    lines
  end.join("\n")
end

#var(name) ⇒ Object



29
30
31
# File 'lib/tcl/interp.rb', line 29

def var(name)
  Tcl::Var.find(self, name)
end

#varsObject



37
38
39
# File 'lib/tcl/interp.rb', line 37

def vars
  list_to_array _!(:info, :vars)
end