6 changed files with 25 additions and 22 deletions
@ -1,13 +1,16 @@ |
|||||||
module FormattingHelper |
module FormattingHelper |
||||||
def ensure_punctuation(value) |
def format_ending(value) |
||||||
return value if value.blank? |
return value if value.blank? |
||||||
|
|
||||||
value.match?(/[[:punct:]]\z/) && !value.match?(/[%(){}\[\]]\z/) ? value : "#{value}." |
ends_with_any_punctuation = value.match?(/[[:punct:]]\z/) |
||||||
|
ends_with_special_char = value.match?(/[%(){}\[\]]\z/) |
||||||
|
|
||||||
|
ends_with_any_punctuation && !ends_with_special_char ? value : "#{value}." |
||||||
end |
end |
||||||
|
|
||||||
def downcase_first_letter(sentence) |
def downcase_first_letter(text) |
||||||
return sentence if sentence.blank? |
return text if text.blank? |
||||||
|
|
||||||
sentence[0].downcase + sentence[1..] |
text[0].downcase + text[1..] |
||||||
end |
end |
||||||
end |
end |
||||||
|
|||||||
Loading…
Reference in new issue