@!attribute [rw] and type (String, Integer...) ?

65 views
Skip to first unread message

Denis BEURIVE

unread,
May 28, 2013, 8:28:57 AM5/28/13
to yar...@googlegroups.com
Hello!

I am trying to document an attribute which is readable and writable. My question is : how do I specify the type of the value ?

For example, in the following code, the attribut "date_format" is a string. How do I specify it ?

module UtilsDateTime
  @date_format = '%Y-%m-%d %H:%M:%S%z'
  
  class << self
    # @!attribute [rw] date_format
    # Get or set the format used to parse date and time strings.
    attr_accessor :date_format
  end
end

Thank you,

Denis


Loren Segal

unread,
May 28, 2013, 5:05:46 PM5/28/13
to yar...@googlegroups.com
Hi Denis,

You would use a @return tag to specify the return type of the attribute:

# @!attribute [rw] date_format
#   @return [String] the format used to parse the date and time strings.
attr_accessor :date_format

Note that the return tag text will be used as the attribute's description when a normal docstring is omitted, so this should shorten your docs when using the return tag alongside your description.

Regards,

Loren

--
 
---
You received this message because you are subscribed to the Google Groups "YARD" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yardoc+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages