Browse Source

Improve formatting helper

CLDC-3740-Replace-you-didnt-answer-with-link
Manny Dinssa 1 month ago
parent
commit
a6c82da043
  1. 5
      app/helpers/formatting_helper.rb

5
app/helpers/formatting_helper.rb

@ -2,8 +2,7 @@ module FormattingHelper
def format_ending(text)
return text if text.blank?
first_word = text.split.first
modified_text = first_word == first_word.upcase ? text : lowercase_first_letter(text)
modified_text = lowercase_first_letter(text)
ensure_sentence_ending(modified_text)
end
@ -17,6 +16,8 @@ module FormattingHelper
end
def lowercase_first_letter(text)
first_word = text.split.first
return text if first_word == first_word.upcase
return text if text.blank?
text[0].downcase + text[1..]

Loading…
Cancel
Save