Class: Tcl::Interp

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#_, #_!

Class Method Details

.load_from_file(filename) ⇒ Object



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

def load_from_file(filename)
  new.tap { _1.eval(File.read(filename)) }
end

Instance Method Details

#expose(name) ⇒ Object



19
20
21
# File 'lib/tcl/interp.rb', line 19

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

#interpObject



11
12
13
# File 'lib/tcl/interp.rb', line 11

def interp
  self
end

#interp_receive(method, *args) ⇒ Object



15
16
17
# File 'lib/tcl/interp.rb', line 15

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

#proc(name) ⇒ Object



23
24
25
# File 'lib/tcl/interp.rb', line 23

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

#procsObject



31
32
33
# File 'lib/tcl/interp.rb', line 31

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

#to_tclObject



39
40
41
42
43
44
45
46
# File 'lib/tcl/interp.rb', line 39

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

#var(name) ⇒ Object



27
28
29
# File 'lib/tcl/interp.rb', line 27

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

#varsObject



35
36
37
# File 'lib/tcl/interp.rb', line 35

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