app/helpers/application_helper.rb
# Finds the longest word in the string (with a word being defined as something without spaces)
# and returns a string with a max-width attribute assigned to be 0.6 times (in em) the length of 
# the longest word if the longest word is longer than 42 characters
Finds the longest word in the string (with a word being defined as something without spaces)
and returns a string with a max-width attribute assigned to be 0.6 times (in em) the length of
the longest word if the longest word is longer than 42 characters
Finds the longest word in the string ( with a word being defined as something without spaces ) and returns a string with a max - width attribute assigned to be 0 . 6 times ( in em ) the length of the longest word if the longest word is longer than 42 characters
def max_width_by_word(string)
    if !string.empty? && string.split(" ").sort_by(&:length).last.length > 42
      return "max-width:#{string.split(" ").sort_by(&:length).last.length * 0.6}em;"
    end
    return ""
  end
def max_width_by_word ( string ) if ! string . empty? && string . split ( " " ) . sort_by ( & :length ) . last . length > 42 return "max-width:#{string.split(" ").sort_by(&:length).last.length * 0.6}em;" end return "" end
Finds the longest word in the string (with a word being defined as something without spaces)
and returns a string with a max-width attribute assigned to be 0.6 times (in em) the length of
the longest word if the longest word is longer than 42 characters
Finds the longest word in the string ( with a word being defined as something without spaces ) and returns a string with a max - width attribute assigned to be 0 . 6 times ( in em ) the length of the longest word if the longest word is longer than 42 characters
string