return values in rdoc method header

Discussion in 'Ruby' started by Jason Lillywhite, Oct 28, 2009.

  1. 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.
    --
    Posted via http://www.ruby-forum.com/.
     
    Jason Lillywhite, Oct 28, 2009
    #1
    1. Advertisements

  2. Jason Lillywhite wrote:
    > 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

    -------------------------
    Note the empty line between the method description header and the main
    description.

    Marvin
    --
    Posted via http://www.ruby-forum.com/.
     
    Marvin Gülker, Oct 28, 2009
    #2
    1. Advertisements

  3. Marvin Gülker wrote:

    > #call-seq:



    Thank you. I have not yet found that in the documentation, but that
    answers my question.
    --
    Posted via http://www.ruby-forum.com/.
     
    Jason Lillywhite, Oct 28, 2009
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mlt
    Replies:
    2
    Views:
    1,119
    Jean-Marc Bourguet
    Jan 31, 2009
  2. Shekhar
    Replies:
    0
    Views:
    263
    Shekhar
    Jul 16, 2004
  3. Andreas Schwarz
    Replies:
    6
    Views:
    481
    Randy W. Sims
    Jan 1, 2004
  4. Brian Schröder
    Replies:
    5
    Views:
    301
    Dave Thomas
    Sep 18, 2004
  5. Daniel Berger
    Replies:
    1
    Views:
    253
    Dave Thomas
    Nov 2, 2004
  6. Iwan van der Kleyn

    rdoc: how to add readme.rdoc as index.html?

    Iwan van der Kleyn, Apr 26, 2005, in forum: Ruby
    Replies:
    1
    Views:
    338
    Stefan Lang
    Apr 26, 2005
  7. Paul Van Delst

    How to use rdoc parsers outside of rdoc?

    Paul Van Delst, Jul 27, 2006, in forum: Ruby
    Replies:
    0
    Views:
    201
    Paul Van Delst
    Jul 27, 2006
  8. Iñaki Baz Castillo
    Replies:
    3
    Views:
    256
    Eric Hodel
    Jul 28, 2009
Loading...