You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: preview_helper.rb
    path of file: ./repos/on_ruby/app/helpers
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module PreviewHelper
  def material_preview(material)
    return '' if material.prev
    
  def material_preview(material)
    return '' if material.preview_type.nil? || (material.preview_type == 'none')

    if material.preview_type == 'video'
      tag.div(class: 'preview video') do
        material.preview_code.html_safe
      end
    elsif material.preview_type == 'image'
      tag.div(class: 'preview image') do
        link_to material.url, title: material.name do
          image_tag(material.preview_code, alt: material.name)
        end
      end
    end