summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-29 03:56:22 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-29 03:56:22 +0000
commitd50547c22c5a884d90d434adef20a9217d88da22 (patch)
tree9b06164a3e7662cd4bcdb49854cf1ac9ace1d291 /variable.c
parent685a063a15d8f18b2f4c849b1faa1158e614eaba (diff)
Add RDoc for Kernel global functions, tidy array and error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/variable.c b/variable.c
index 2a7b795..17832df 100644
--- a/variable.c
+++ b/variable.c
@@ -531,6 +531,29 @@ rb_trace_eval(cmd, val)
rb_eval_cmd(cmd, rb_ary_new3(1, val), 0);
}
+/*
+ * call-seq:
+ * trace_var(symbol, cmd ) => nil
+ * trace_var(symbol) {|val| block } => nil
+ *
+ * Controls tracing of assignments to global variables. The parameter
+ * +symbol_ identifies the variable (as either a string name or a
+ * symbol identifier). _cmd_ (which may be a string or a
+ * +Proc+ object) or block is executed whenever the variable
+ * is assigned. The block or +Proc+ object receives the
+ * variable's new value as a parameter. Also see
+ * <code>Kernel::untrace_var</code>.
+ *
+ * trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
+ * $_ = "hello"
+ * $_ = ' there'
+ *
+ * <em>produces:</em>
+ *
+ * $_ is now 'hello'
+ * $_ is now ' there'
+ */
+
VALUE
rb_f_trace_var(argc, argv)
int argc;
@@ -584,6 +607,16 @@ remove_trace(var)
var->trace = t.next;
}
+/*
+ * call-seq:
+ * untrace_var(symbol [, cmd] ) => array or nil
+ *
+ * Removes tracing for the specified command on the given global
+ * variable and returns +nil+. If no command is specified,
+ * removes all tracing for that variable and returns an array
+ * containing the commands actually removed.
+ */
+
VALUE
rb_f_untrace_var(argc, argv)
int argc;
@@ -722,6 +755,15 @@ gvar_i(key, entry, ary)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * global_variables => array
+ *
+ * Returns an array of the names of global variables.
+ *
+ * global_variables.grep /std/ #=> ["$stderr", "$stdout", "$stdin"]
+ */
+
VALUE
rb_f_global_variables()
{