Sha256: 2e4e3182c6277dcb46e23c0081457ee89e14b9bcfbaaf1c14e0dc1bc84fcd1b0

Contents?: true

Size: 740 Bytes

Versions: 6

Compression:

Stored size: 740 Bytes

Contents

##
# Pretifies reports
class Reportinator

  ##
  # Generates a banner for a message based on the length of the message or a
  # given width.
  # ==== Attributes
  #
  # * _message_:  The message to put.
  # * _width_:    The width of the message. If nil the size of the banner is
  # determined by the length of the message.
  #
  # ==== Examples
  #
  #    rp = Reportinator.new
  #    rp.generate_banner("Hello world!") => "------------\nHello world!\n------------\n" 
  #    rp.generate_banner("Hello world!", 3) => "---\nHello world!\n---\n" 
  #
  #
  def generate_banner(message, width=nil)
    dash_count = ((width.nil?) ? message.strip.length : width)
    return "#{'-' * dash_count}\n#{message}\n#{'-' * dash_count}\n"
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ceedling-0.31.1 lib/ceedling/reportinator.rb
ceedling-0.31.0 lib/ceedling/reportinator.rb
ceedling-0.30.0 lib/ceedling/reportinator.rb
ceedling-0.28.3 lib/ceedling/reportinator.rb
ceedling-0.28.2 lib/ceedling/reportinator.rb
ceedling-0.28.1 lib/ceedling/reportinator.rb