class Fuelcell::Help::DescFormatter

Public Instance Methods

call(data) click to toggle source
# File lib/fuelcell/help/desc_formatter.rb, line 5
def call(data)
  return '' if empty?(data)
  wrap(data[:long_desc] || data[:desc]) + "\n"
end
empty?(data) click to toggle source
# File lib/fuelcell/help/desc_formatter.rb, line 15
def empty?(data)
  (!data.key?(:desc) || data[:desc].to_s.empty?) &&
    (!data.key?(:long_desc) || data[:long_desc].to_s.empty?)
end
wrap(text) click to toggle source
# File lib/fuelcell/help/desc_formatter.rb, line 10
def wrap(text)
  pattern = /(.{1,#{max_width}})(\s+|$)/
  text.gsub(pattern, "\\1\n").strip
end