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

def _check_ruby(ret, ruby, user=None):
    '''
    Check that ruby is installed
    '''
    match_version = True
    match_micro_version = False
    micro_version_regex = re.compile(r'-([0-9]{4}\.[0-9]{2}|p[0-9]+)$')
    if micro_version_regex.search(ruby):
        match_micro_version = True
    if re.search('^[a-z]+$', ruby):
        match_version = False
    ruby = re.sub('^ruby-', '', ruby)

    for impl, version, default in __salt__['rvm.list'](runas=user):
        if impl != 'ruby':
            version = '{impl}-{version}'.format(impl=impl, version=version)
        if not match_micro_version:
            version = micro_version_regex.sub('', version)
        if not match_version:
            version = re.sub('-.*', '', version)
        if version == ruby:
            ret['result'] = True
            ret['comment'] = 'Requested ruby exists.'
            ret['default'] = default
            break
    return ret