Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Are comments objects?

Reply
Thread Tools

Are comments objects?

 
 
RubyTalk@gmail.com
Guest
Posts: n/a
 
      03-23-2007
Are comment blocks objects? I want to be able to access all (or just
one) the comment blocks for an object. Then I can make a .help for
each object.

a="a"
puts a.help

#{list all methods maybe?}

puts a.help(:split)

"Divides str into substrings based on a delimiter, returning an array
of these substrings.

If pattern is a String, then its contents are used as the delimiter
when splitting str. If pattern is a single space, str is split on
whitespace, with leading whitespace and runs of contiguous whitespace
characters ignored.

If pattern is a Regexp, str is divided where the pattern matches.
Whenever the pattern matches a zero-length string, str is split into
individual characters.

If pattern is omitted, the value of $; is used. If $; is nil (which is
the default), str is split on whitespace as if ` ' were specified.

If the limit parameter is omitted, trailing null fields are
suppressed. If limit is a positive number, at most that number of
fields will be returned (if limit is 1, the entire string is returned
as the only entry in an array). If negative, there is no limit to the
number of fields returned, and trailing null fields are not
suppressed. "

If one can not access comments I can try open the C file and parse the
comment blocks.

Maybe it would not put out that much information but you get the basic idea.

Stephen Becker IV

 
Reply With Quote
 
 
 
 
Jonas Pfenniger
Guest
Posts: n/a
 
      03-23-2007
2007/3/23, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)>:
> Are comment blocks objects? I want to be able to access all (or just
> one) the comment blocks for an object. Then I can make a .help for
> each object.


I've stripped the implementation details. To make a simple answer,
ruby simply ignores the comments when parsing the source code. So the
comments are not available to the ruby interpreter. However, you can
either re-parse the open files or use the ri indexes to fetch the
according methods. Mauricio Fernandez[1] has done some nice job[2] on
comment indexing and methods lookup, based on the initial RDoc work.
If I where you, I would look at that first. Secondly, I think that
there already is a help.rb file in the stdlib that does what you want,
or at least a gem is flying around here.

I hope this helps you go further with your investigations

--
Cheers,
zimbatm

[1] : http://eigenclass.org
[2] : http://rubyforge.org/projects/fastri/

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Javascript 4 06-03-2006 02:00 PM
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Java 0 06-02-2006 06:35 AM
Comments format: comments extending over multi-line Monk C Programming 10 04-20-2005 05:09 PM
Firefox comments and questions? Noozer Firefox 3 04-21-2004 08:29 PM
Firefox 0.8 Comments Ol' Duffer Firefox 5 02-23-2004 01:54 AM



Advertisments