IT Community - Software Programming, Web Development and Technical Support

Ruby BuiltIn functions

This is a discussion on Ruby BuiltIn functions within the Ruby forums, part of the Web Development category; dexp Math.ldexp( aFloat, anInteger ) -> aFloat Returns the value of aFloat *2 anInteger . log Math.log( aNumeric ) -> aFloat ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Ruby

Register FAQ Members List Calendar Mark Forums Read
  #41 (permalink)  
Old 04-17-2008, 01:52 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

dexp
Math.ldexp( aFloat, anInteger ) -> aFloat
Returns the value of aFloat *2 anInteger .

log
Math.log( aNumeric ) -> aFloat
Returns the natural logarithm of aNumeric.

log10

Math.log10( aNumeric ) -> aFloat
Returns the base 10 logarithm of aNumeric.
sin
Math.sin( aNumeric ) -> aFloat
Computes the sine of aNumeric (expressed in radians). Returns -1..1.
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #42 (permalink)  
Old 04-17-2008, 01:56 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

sqrt
Math.sqrt( aNumeric ) -> aFloat
Returns the non-negative square root of aNumeric. Raises ArgError if aNumeric is less than zero.

tan

Math.tan( aNumeric ) -> aFloat
Returns the tangent of aNumeric (expressed in radians).

_id2ref

ObjectSpace._id2ref( anId ) -> anObject


Converts an object id to a reference to the object. May not be called on an object id passed as a parameter to a finalizer.

s = "I am a string" » "I am a string"
r = ObjectSpace._id2ref(s.id) »"I am a string"
r == s »true
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #43 (permalink)  
Old 04-18-2008, 04:47 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

define_finalizer
ObjectSpace.define_finalizer( anObject, aProc=proc() )
Adds aProc as a finalizer, to be called when anObject is about to be destroyed.

each_object
ObjectSpace.each_object( [ aClassOrMod ] ) {| anObj | block } -> aFixnum


Calls the block once for each living, nonimmediate object in this Ruby process. If aClassOrMod is specified, calls the block for only those classes or modules that match (or are a subclass of) aClassOrMod. Returns the number of objects found.

a = 102.7
b = 95
ObjectSpace.each_object(Numeric) {|x| p x }
print "Total count: ", ObjectSpace.each_object {} ,"\n"

produces:

102.7
2.718281828
3.141592654
Total count: 372

garbage_collect ObjectSpace.garbage_collect -> nil
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #44 (permalink)  
Old 04-18-2008, 04:49 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

undefine_finalizer
ObjectSpace.undefine_finalizer( anObject )
Removes all finalizers for anObject.


egid

Process.egid -> aFixnum
Returns the effective group id for this process.
Process.egid » 500


egid=

Process.egid= aFixnum -> aFixnum
Sets the effective group id for this process.
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #45 (permalink)  
Old 04-19-2008, 12:14 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

euid
Process.euid -> aFixnum
Returns the effective user id for this process.
process.euid » 501

euid=
Process.euid= aFixnum
Sets the effective user id for this process. Not available on all platforms.

exit!

Process.exit!( aFixnum=-1 )
Exits the process immediately. No exit handlers are run. aFixnum is returned to the underlying system as the exit status.

Process.exit!(0)
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #46 (permalink)  
Old 04-19-2008, 12:15 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

getpgid
Process.getpgid( anInteger ) -> anInteger
Returns the process group id for the given process id. Not available on all platforms.
Process.getpgid(Process.ppid()) » 32438

getpgrp
Process.getpgrp -> anInteger
Returns the process group id for this process. Not available on all platforms.
Process.getpgid(0) » 32438
Process.getpgrp » 32438
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #47 (permalink)  
Old 04-19-2008, 12:16 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

getpriority
process.getpriority( aKind, anInteger ) -> aFixnum
Gets the scheduling priority for specified process, process group, or user. aKind indicates the kind of entity to find: one of Process::PRIO_PGRP , Process::PRIO_USER , or Process::PRIO_PROCESS . anInteger is an id indicating the particular process, process group, or user (an id of 0 means current). Lower priorities are more favorable for scheduling. Not available on all platforms.

Process.getpriority(Process::PRIO_USER, 0) » 0
Process.getpriority(Process::PRIO_PROCESS, 0) » 0

gid
process.gid -> aFixnum
Returns the group id for this process.
Process.gid » 500
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #48 (permalink)  
Old 04-19-2008, 12:21 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

gid
Process.gid -> aFixnum
Returns the group id for this process.
Process.gid » 500

gid=

Process.gid= aFixnum -> aFixnum
Sets the group id for this process.

kill
Process.kill( aSignal, [ aPid ]+ ) -> aFixnum


Sends the given signal to the specified process id(s), or to the current process if aPid is zero. aSignal may be an integer signal number or a POSIX signal name (either with or without a SIG prefix). If aSignal is negative (or starts with a ``-'' sign), kills process groups instead of processes. Not all signals are available on all platforms.

trap("SIGHUP") { close_then_exit }
Process.kill("SIGHUP", 0)

pid
Process.pid -> aFixnum
Returns the process id of this process. Not available on all platforms.
Process.pid » 1488
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #49 (permalink)  
Old 04-21-2008, 04:05 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

ppid
Process.ppid -> aFixnum

Returns the process id of the parent of this process. Always returns 0 on NT. Not available on all platforms.

print "I am ", Process.pid, "\n"
Process.fork { print "Dad is ", Process.ppid, "\n" }

produces:


I am 1490
Dad is 1490

setpgid
Process.setpgid( aPid, anInteger ) -> 0
Sets the process group id of aPid (0 indicates this process) to anInteger. Not available on all platforms.

setpgrp

Process.setpgrp -> 0
Equivalent to setpgid(0,0). Not available on all platforms.
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #50 (permalink)  
Old 04-22-2008, 07:58 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

setsid
Process.setsid -> aFixnum
Establishes this process as a new session and process group leader, with no controlling tty. Returns the session id. Not available on all platforms.
Process.setsid » 1495

uid

Process.uid -> aFixnum
Returns the user id of this process.
Process.uid » 501
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #51 (permalink)  
Old 04-22-2008, 07:59 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

uid=
Process.uid= anInteger -> aNumeric
Sets the (integer) user id for this process. Not available on all platforms.

wait

Process.wait -> aFixnum

Waits for any child process to exit and returns the process id of that child. Raises a SystemError if there are no child processes. Not available on all platforms.

Process.fork { exit 1; } » 1500
Process.wait » 1500
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #52 (permalink)  
Old 04-22-2008, 08:01 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

wait2
Process.wait2 -> anArray
Waits for any child process to exit and returns an array containing the process id and the exit status of that child. Raises a SystemError if there are no child processes.
Process.fork { exit 1 } » 1503
Process.wait2 » [1503, 256]

waitpid

Process.waitpid( aPid, anInteger=0 ) -> aPid
Waits for the given child process to exit. anInteger may be a logical or of the flag value Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms.

include Process
pid = fork { sleep 3 } » 1506
Time.now » Sun Jun 09 00:20:09 CDT 2002
waitpid(pid, Process::WNOHANG) » nil
Time.now » Sun Jun 09 00:20:09 CDT 2002
waitpid(pid, 0) » 1506
Time.now » Sun Jun 09 00:20:12 CDT 2002
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #53 (permalink)  
Old 04-22-2008, 08:01 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

waitpid2
Process.waitpid2( aPid, anInteger=0 ) -> anArray


Waits for the given child process to exit, returning that child's process id and exit status. anInteger may be a logical or of the flag value Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms.
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Ruby for Web? S.Vinothkumar Ruby 6 11-20-2007 01:25 AM
What are Virtual Functions? How to implement virtual functions in "C"? Sabari C and C++ Programming 4 09-10-2007 10:35 PM
What Is RUBY? theseokit Ruby 7 03-12-2007 11:43 PM
Ruby within .NET? econwriter5 Ruby 0 03-07-2007 05:02 PM
Ruby IDE drecko Ruby 0 02-16-2007 12:11 AM


All times are GMT -7. The time now is 02:56 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0