Respostas:
Existem métodos integrados:
"String".start_with? "S" # true
"String".end_with? "4" # false
starts_with?
e ends_with?
.
"The string".starts_with?
string.start_with?("substring")
string.end_with?("substring")
Retorna verdadeiro ou falso
Fonte:
http://ruby-doc.org//core-2.2.0/String.html#method-i-start_with-3F
http://ruby-doc.org//core-2.2.0/String.html#method-i-end_with-3F