Module: Upworthy

Defined in:
lib/upworthy.rb

Overview

Namespace for constants and methods needed to generate headlines.

Author:

  • William Woodruff

Since:

  • 0.0.1

Class Method Summary collapse

Class Method Details

.headlineString

Generates a new clickbait headline.

Examples:

Upworthy.headline # => "Watch an extroverted police officer become a legend with six words"

Returns:

  • (String)

    the headline

Since:

  • 0.0.1



403
404
405
406
407
# File 'lib/upworthy.rb', line 403

def self.headline
  content = Hash[CONTENT.map { |k, v| [k, v.sample] }]

  (HEADLINES.sample % content).gsub("  ", " ")
end