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. Advertising

  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. Advertising

  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. Advertising

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:
    917
    Jean-Marc Bourguet
    Jan 31, 2009
  2. Andreas Schwarz
    Replies:
    6
    Views:
    284
    Randy W. Sims
    Jan 1, 2004
  3. Brian Schröder
    Replies:
    5
    Views:
    165
    Dave Thomas
    Sep 18, 2004
  4. Daniel Berger
    Replies:
    1
    Views:
    157
    Dave Thomas
    Nov 2, 2004
  5. Iñaki Baz Castillo
    Replies:
    3
    Views:
    163
    Eric Hodel
    Jul 28, 2009
Loading...

Share This Page