rubyyardtruthiness

YARD convention for truthiness


Is there a convention to indicate that a parameter in YARD style documentation is only used for its "truthiness" status, that is you only want to know if it's false or nil or is truthy?

What is typically put in place of Truthy in the following?

# @param [String] name
# @param [Truthy] admin_status 
def create_user(name, admin_status)
  # code goes here
end

The closest I can find in the documentation is Boolean, which isn't really what I want.


Solution

  • Using anything other than Boolean would imply that you're doing some sort of special handling, like interpreting 0 as false or something less literal than true/false checking.

    You can see the convention used in the YARD docs where Boolean represents both the TrueClass and FalseClass types. This type does not exist in Ruby, however.