ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PK]HJ# eval-i.rinu[U:RDoc::AnyMethod[iI" eval:ETI"Binding#eval;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"AEvaluates the Ruby expression(s) in string, in the ;TI"Hbinding's context. If the optional filename and ;TI"Dlineno parameters are present, they will be used when ;TI"reporting syntax errors.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"def get_binding(param) ;TI" binding ;TI" end ;TI"b = get_binding("hello") ;TI""b.eval("param") #=> "hello";T: @format0: @fileI" proc.c;T:0@omit_headings_from_table_of_contents_below0I"9binding.eval(string [, filename [,lineno]]) -> obj ;T0[I"(p1, p2 = v2, p3 = v3);T@FI" Binding;TcRDoc::NormalClass00PK]source_location-i.rinu[U:RDoc::AnyMethod[iI"source_location:ETI"Binding#source_location;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LReturns the Ruby source filename and line number of the binding object.;T: @fileI" proc.c;T:0@omit_headings_from_table_of_contents_below0I"3binding.source_location -> [String, Integer] ;T0[I"();T@FI" Binding;TcRDoc::NormalClass00PK]Tlocal_variable_defined%3f-i.rinu[U:RDoc::AnyMethod[iI"local_variable_defined?:ETI"$Binding#local_variable_defined?;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"8Returns +true+ if a local variable +symbol+ exists.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I" def foo ;TI" a = 1 ;TI"4 binding.local_variable_defined?(:a) #=> true ;TI"5 binding.local_variable_defined?(:b) #=> false ;TI" end ;T: @format0o; ; [I" obj ;T0[I" (p1);T@FI" Binding;TcRDoc::NormalClass00PK]a=llocal_variable_get-i.rinu[U:RDoc::AnyMethod[iI"local_variable_get:ETI"Binding#local_variable_get;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"6Returns the value of the local variable +symbol+.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I" def foo ;TI" a = 1 ;TI", binding.local_variable_get(:a) #=> 1 ;TI"4 binding.local_variable_get(:b) #=> NameError ;TI" end ;T: @format0o; ; [I" obj ;T0[I" (p1);T@FI" Binding;TcRDoc::NormalClass00PK] RRlocal_variable_set-i.rinu[U:RDoc::AnyMethod[iI"local_variable_set:ETI"Binding#local_variable_set;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"0Set local variable named +symbol+ as +obj+.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I" def foo ;TI" a = 1 ;TI" bind = binding ;TI"H bind.local_variable_set(:a, 2) # set existing local variable `a' ;TI"F bind.local_variable_set(:b, 3) # create new local variable `b' ;TI"C # `b' exists only in binding ;TI" ;TI", p bind.local_variable_get(:a) #=> 2 ;TI", p bind.local_variable_get(:b) #=> 3 ;TI", p a #=> 2 ;TI"4 p b #=> NameError ;TI" end ;T: @format0o; ; [I"9This method behaves similarly to the following code:;T@o; ; [I"(binding.eval("#{symbol} = #{obj}") ;T; 0o; ; [I")if +obj+ can be dumped in Ruby code.;T: @fileI" proc.c;T:0@omit_headings_from_table_of_contents_below0I"4binding.local_variable_set(symbol, obj) -> obj ;T0[I" (p1, p2);T@&FI" Binding;TcRDoc::NormalClass00PK] local_variables-i.rinu[U:RDoc::AnyMethod[iI"local_variables:ETI"Binding#local_variables;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"CReturns the names of the binding's local variables as symbols.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I" def foo ;TI" a = 1 ;TI" 2.times do |n| ;TI". binding.local_variables #=> [:a, :n] ;TI" end ;TI" end ;T: @format0o; ; [I" Array ;T0[I"();T@FI" Binding;TcRDoc::NormalClass00PK],,cdesc-Binding.rinu[U:RDoc::NormalClass[iI" Binding:ET@I" Object;To:RDoc::Markup::Document: @parts[o;;[: @fileI"lib/irb.rb;T:0@omit_headings_from_table_of_contents_below0o;;[; I"prelude.rb;T; 0o;;[ o:RDoc::Markup::Paragraph;[ I"HObjects of class Binding encapsulate the execution context at some ;TI"Eparticular place in the code and retain this context for future ;TI"Buse. The variables, methods, value of self, and ;TI"Epossibly an iterator block that can be accessed in this context ;TI" 99 ;TI""eval("@secret", b2) #=> -3 ;TI"#eval("@secret") #=> nil ;T: @format0o; ;[I"4Binding objects have no class-specific methods.;T; I" proc.c;T; 0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[;[[;[[;[ [I" eval;TI" proc.c;T[I"irb;TI"lib/irb.rb;T[I"local_variable_defined?;T@Q[I"local_variable_get;T@Q[I"local_variable_set;T@Q[I"local_variables;T@Q[I" receiver;T@Q[I"source_location;T@Q[[U:RDoc::Context::Section[i0o;;[; 0; 0[I"lib/irb.rb;TI"prelude.rb;TI" proc.c;T@8cRDoc::TopLevelPK]F?]] receiver-i.rinu[U:RDoc::AnyMethod[iI" receiver:ETI"Binding#receiver;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"6Returns the bound receiver of the binding object.;T: @fileI" proc.c;T:0@omit_headings_from_table_of_contents_below0I"#binding.receiver -> object ;T0[I"();T@FI" Binding;TcRDoc::NormalClass00PK](xirb-i.rinu[U:RDoc::AnyMethod[iI"irb:ETI"Binding#irb;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"IOpens an IRB session where +binding.irb+ is called which allows for ;TI"Ointeractive debugging. You can call any methods or variables available in ;TI"8the current scope, and mutate state if you need to.;To:RDoc::Markup::BlankLineo; ; [I"HGiven a Ruby file called +potato.rb+ containing the following code:;T@o:RDoc::Markup::Verbatim; [I"class Potato ;TI" def initialize ;TI" @cooked = false ;TI" binding.irb ;TI"* puts "Cooked potato: #{@cooked}" ;TI" end ;TI" end ;TI" ;TI"Potato.new ;T: @format0o; ; [I"HRunning ruby potato.rb will open an IRB session where ;TI"=+binding.irb+ is called, and you will see the following:;T@o; ; [I"$ ruby potato.rb ;TI" ;TI" From: potato.rb @ line 4 : ;TI" ;TI" 1: class Potato ;TI" 2: def initialize ;TI" 3: @cooked = false ;TI" => 4: binding.irb ;TI"1 5: puts "Cooked potato: #{@cooked}" ;TI" 6: end ;TI" 7: end ;TI" 8: ;TI" 9: Potato.new ;TI" ;TI".irb(#):001:0> ;T; 0o; ; [I"NYou can type any valid Ruby code and it will be evaluated in the current ;TI"Rcontext. This allows you to debug without having to run your code repeatedly:;T@o; ; [ I"6irb(#):001:0> @cooked ;TI"=> false ;TI"9irb(#):002:0> self.class ;TI"=> Potato ;TI";irb(#):003:0> caller.first ;TI"A=> ".../2.5.1/lib/ruby/2.5.0/irb/workspace.rb:85:in `eval'" ;TI"=irb(#):004:0> @cooked = true ;TI" => true ;T; 0o; ; [I"RYou can exit the IRB session with the +exit+ command. Note that exiting will ;TI"Qresume execution where +binding.irb+ had paused it, as you can see from the ;TI"7output printed to standard output in this example:;T@o; ; [I"3irb(#):005:0> exit ;TI"Cooked potato: true ;T; 0o; ; [I",See IRB@IRB+Usage for more information.;T: @fileI"lib/irb.rb;T:0@omit_headings_from_table_of_contents_below000[I"();T@NFI" Binding;TcRDoc::NormalClass00PK]HJ# eval-i.rinu[PK]3source_location-i.rinu[PK]Tlocal_variable_defined%3f-i.rinu[PK]a=lPlocal_variable_get-i.rinu[PK] RRY local_variable_set-i.rinu[PK] local_variables-i.rinu[PK],,cdesc-Binding.rinu[PK]F?]] Wreceiver-i.rinu[PK](xirb-i.rinu[PK $