<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def installed(name, default=False, user=None):
    '''
    Verify that the specified ruby is installed with rbenv. Rbenv is
    installed if necessary.

    name
        The version of ruby to install

    default : False
        Whether to make this ruby the default.

    user: None
        The user to run rbenv as.

        .. versionadded:: 0.17.0

    .. versionadded:: 0.16.0
    '''
    ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
    rbenv_installed_ret = copy.deepcopy(ret)

    if name.startswith('ruby-'):
        name = re.sub(r'^ruby-', '', name)

    if __opts__['test']:
        ret = _ruby_installed(ret, name, user=user)
        if not ret['result']:
            ret['comment'] = 'Ruby {0} is set to be installed'.format(name)
        else:
            ret['comment'] = 'Ruby {0} is already installed'.format(name)
        return ret

    rbenv_installed_ret = _check_and_install_rbenv(rbenv_installed_ret, user)
    if rbenv_installed_ret['result'] is False:
        ret['result'] = False
        ret['comment'] = 'Rbenv failed to install'
        return ret
    else:
        return _check_and_install_ruby(ret, name, default, user=user)