# File lib/isbn-converter.rb, line 5
def to13(isbn)
        isbn = clean(isbn)
        if isbn.length == 13 && ["978","979"].member?(isbn[0..2])
                return isbn
        elsif isbn.length != 10
                return nil
        end
        new_isbn = "978" + isbn.chop
        check = 0
        new_isbn.split(//).each_with_index do |digit, index|
                if index % 2 == 0
                        check += digit.to_i * 1
                else
                        check += digit.to_i * 3
                end
        end
        check = if check % 10 == 0 then 0 else 10 - (check % 10) end
        new_isbn + check.to_s
end