doc: improve documentation for Binding [ci skip]
* remove explicit return from code examples * grammar fixes * other small fixes Patch by: Marcus Stollsteimer <sto.mar@web.de> [ruby-core:79082] [Bug #13132] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8e0ff63f22
commit
103a6a4cbd
37
proc.c
37
proc.c
@ -353,7 +353,7 @@ rb_binding_new(void)
|
|||||||
* environment. See also the description of class +Binding+.
|
* environment. See also the description of class +Binding+.
|
||||||
*
|
*
|
||||||
* def get_binding(param)
|
* def get_binding(param)
|
||||||
* return binding
|
* binding
|
||||||
* end
|
* end
|
||||||
* b = get_binding("hello")
|
* b = get_binding("hello")
|
||||||
* eval("param", b) #=> "hello"
|
* eval("param", b) #=> "hello"
|
||||||
@ -375,7 +375,7 @@ rb_f_binding(VALUE self)
|
|||||||
* reporting syntax errors.
|
* reporting syntax errors.
|
||||||
*
|
*
|
||||||
* def get_binding(param)
|
* def get_binding(param)
|
||||||
* return binding
|
* binding
|
||||||
* end
|
* end
|
||||||
* b = get_binding("hello")
|
* b = get_binding("hello")
|
||||||
* b.eval("param") #=> "hello"
|
* b.eval("param") #=> "hello"
|
||||||
@ -446,7 +446,7 @@ check_local_id(VALUE bindval, volatile VALUE *pname)
|
|||||||
* call-seq:
|
* call-seq:
|
||||||
* binding.local_variables -> Array
|
* binding.local_variables -> Array
|
||||||
*
|
*
|
||||||
* Returns the +symbol+ names of the binding's local variables
|
* Returns the names of the binding's local variables as symbols.
|
||||||
*
|
*
|
||||||
* def foo
|
* def foo
|
||||||
* a = 1
|
* a = 1
|
||||||
@ -455,7 +455,7 @@ check_local_id(VALUE bindval, volatile VALUE *pname)
|
|||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* This method is short version of the following code.
|
* This method is the short version of the following code:
|
||||||
*
|
*
|
||||||
* binding.eval("local_variables")
|
* binding.eval("local_variables")
|
||||||
*
|
*
|
||||||
@ -475,7 +475,7 @@ bind_local_variables(VALUE bindval)
|
|||||||
* call-seq:
|
* call-seq:
|
||||||
* binding.local_variable_get(symbol) -> obj
|
* binding.local_variable_get(symbol) -> obj
|
||||||
*
|
*
|
||||||
* Returns a +value+ of local variable +symbol+.
|
* Returns the value of the local variable +symbol+.
|
||||||
*
|
*
|
||||||
* def foo
|
* def foo
|
||||||
* a = 1
|
* a = 1
|
||||||
@ -483,7 +483,7 @@ bind_local_variables(VALUE bindval)
|
|||||||
* binding.local_variable_get(:b) #=> NameError
|
* binding.local_variable_get(:b) #=> NameError
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* This method is short version of the following code.
|
* This method is the short version of the following code:
|
||||||
*
|
*
|
||||||
* binding.eval("#{symbol}")
|
* binding.eval("#{symbol}")
|
||||||
*
|
*
|
||||||
@ -520,18 +520,19 @@ bind_local_variable_get(VALUE bindval, VALUE sym)
|
|||||||
* bind = binding
|
* bind = binding
|
||||||
* bind.local_variable_set(:a, 2) # set existing local variable `a'
|
* bind.local_variable_set(:a, 2) # set existing local variable `a'
|
||||||
* bind.local_variable_set(:b, 3) # create new local variable `b'
|
* bind.local_variable_set(:b, 3) # create new local variable `b'
|
||||||
* # `b' exists only in binding.
|
* # `b' exists only in binding
|
||||||
* p bind.local_variable_get(:a) #=> 2
|
*
|
||||||
* p bind.local_variable_get(:b) #=> 3
|
* p bind.local_variable_get(:a) #=> 2
|
||||||
* p a #=> 2
|
* p bind.local_variable_get(:b) #=> 3
|
||||||
* p b #=> NameError
|
* p a #=> 2
|
||||||
|
* p b #=> NameError
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* This method is a similar behavior of the following code
|
* This method behaves similarly to the following code:
|
||||||
*
|
*
|
||||||
* binding.eval("#{symbol} = #{obj}")
|
* binding.eval("#{symbol} = #{obj}")
|
||||||
*
|
*
|
||||||
* if obj can be dumped in Ruby code.
|
* if +obj+ can be dumped in Ruby code.
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val)
|
bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val)
|
||||||
@ -560,7 +561,7 @@ bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val)
|
|||||||
* call-seq:
|
* call-seq:
|
||||||
* binding.local_variable_defined?(symbol) -> obj
|
* binding.local_variable_defined?(symbol) -> obj
|
||||||
*
|
*
|
||||||
* Returns a +true+ if a local variable +symbol+ exists.
|
* Returns +true+ if a local variable +symbol+ exists.
|
||||||
*
|
*
|
||||||
* def foo
|
* def foo
|
||||||
* a = 1
|
* a = 1
|
||||||
@ -568,7 +569,7 @@ bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val)
|
|||||||
* binding.local_variable_defined?(:b) #=> false
|
* binding.local_variable_defined?(:b) #=> false
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* This method is short version of the following code.
|
* This method is the short version of the following code:
|
||||||
*
|
*
|
||||||
* binding.eval("defined?(#{symbol}) == 'local-variable'")
|
* binding.eval("defined?(#{symbol}) == 'local-variable'")
|
||||||
*
|
*
|
||||||
@ -1086,7 +1087,7 @@ iseq_location(const rb_iseq_t *iseq)
|
|||||||
* prc.source_location -> [String, Integer]
|
* prc.source_location -> [String, Integer]
|
||||||
*
|
*
|
||||||
* Returns the Ruby source filename and line number containing this proc
|
* Returns the Ruby source filename and line number containing this proc
|
||||||
* or +nil+ if this proc was not defined in Ruby (i.e. native)
|
* or +nil+ if this proc was not defined in Ruby (i.e. native).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -2468,7 +2469,7 @@ rb_obj_method_location(VALUE obj, ID id)
|
|||||||
* meth.source_location -> [String, Integer]
|
* meth.source_location -> [String, Integer]
|
||||||
*
|
*
|
||||||
* Returns the Ruby source filename and line number containing this method
|
* Returns the Ruby source filename and line number containing this method
|
||||||
* or nil if this method was not defined in Ruby (i.e. native)
|
* or nil if this method was not defined in Ruby (i.e. native).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -3125,7 +3126,7 @@ Init_Proc(void)
|
|||||||
* @secret = n
|
* @secret = n
|
||||||
* end
|
* end
|
||||||
* def get_binding
|
* def get_binding
|
||||||
* return binding()
|
* binding
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user