Class: Label::DescriptionFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/label/description_formatter.rb

Constant Summary collapse

FIRST_SENTENCE_REGEXP =
/(?<first_sentence>([^.]*https?:\/\/[^\s]*\..*\..*)|([^.]*\.))(?<rest>.*)/
CHARACTERS_PER_LINE =
90

Class Method Summary collapse

Class Method Details

.format(description, separator = '') ⇒ Object

Formats a description

description - A description String to be formatted. separator - A String to be used as aditional separator formatting



11
12
13
14
15
16
17
# File 'lib/label/description_formatter.rb', line 11

def self.format description, separator = ''
  if md = description.match(FIRST_SENTENCE_REGEXP)
    break_in_lines md[:first_sentence].strip, separator
  else
    "#{separator} #{description}"
  end
end