Class: Tcl::Proc
Constant Summary
collapse
- BUILTINS =
%w[
auto_execok auto_import auto_load auto_load_index
auto_qualify tclLog unknown
].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Delegator
included, #method_missing, #respond_to_missing?
Methods included from Utils
#_, #_!
Constructor Details
#initialize(interp, name) ⇒ Proc
Returns a new instance of Proc.
12
13
14
15
16
|
# File 'lib/tcl/proc.rb', line 12
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::Delegator
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10
11
12
|
# File 'lib/tcl/proc.rb', line 10
def name
@name
end
|
Instance Method Details
#arguments ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/tcl/proc.rb', line 18
def arguments
list_to_array(_!(:info, :args, name)).map do |argument_name|
variable_name = "__Tcl_Proc_arguments_#{name}_#{argument_name}"
if _!(:info, :default, name, argument_name, variable_name) == '0'
argument_name
else
_(argument_name, var(variable_name).value)
end
ensure
_!(:unset, variable_name)
end
end
|
#body ⇒ Object
31
32
33
|
# File 'lib/tcl/proc.rb', line 31
def body
_!(:info, :body, name)
end
|
#builtin? ⇒ Boolean
43
44
45
46
|
# File 'lib/tcl/proc.rb', line 43
def builtin?
BUILTINS.include?(name)
end
|
#call(*args) ⇒ Object
35
36
37
|
# File 'lib/tcl/proc.rb', line 35
def call(*args)
_!(name, *args.map(&:to_s))
end
|
#to_tcl ⇒ Object
39
40
41
|
# File 'lib/tcl/proc.rb', line 39
def to_tcl
_(:proc, name, _(*arguments), body)
end
|