Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Ruby Programming
Previous Page Home Next Page

The Frame Class

The IRB::Frame class represents the interpreter's stack and allows easy access to the Binding environment in effect at different stack levels.

IRB::Frame.top(n = 0) Returns a Binding for the nth context from the top. The 0th context is topmost, most recent frame.
IRB::Frame.bottom(n = 0) Returns a Binding for the nth context from the bottom. The 0th context is the bottommost, initial frame.
IRB::Frame.sender Returns the object (the sender) that invoked the current method.

You can use this facility, for instance, to examine local variables from the method that called the current method:

require 'irb/frame'

def outie   b = IRB::Frame.top(1)   eval "p my_local", b end

def innie   my_local = 102.7   outie end

innie
produces:
102.7

Note that this doesn't work with multithreaded programs.


Ruby Programming
Previous Page Home Next Page

 
 
  Published under the terms of the Open Publication License Design by Interspire