return values in rdoc method header

J

Jason Lillywhite

The rdoc heading for Array[index] method says:

array[index] = obj → obj

and for String.new:

String.new(str="") => new_str

When I document my own classes, how do I make the part that shows return
values with the arrow appear? i.e. change_array(old_array) => new_array

I don't know how to comment my code such that the "=> new_array" would
appear in rdoc.

Thank you.
 
M

Marvin Gülker

Jason said:
The rdoc heading for Array[index] method says:

array[index] = obj → obj

and for String.new:

String.new(str="") => new_str

When I document my own classes, how do I make the part that shows return
values with the arrow appear? i.e. change_array(old_array) => new_array

I don't know how to comment my code such that the "=> new_array" would
appear in rdoc.

Thank you.

You have to use the call-seq directive for that:
-----------------------

#call-seq:
# my_method(str) ==> aString
# my_method(str, true) ==> anInteger
#
#This is your normal method description.
def my_method(x, y = false)
#Here goes your code...
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top