Sha256: e3f4628d7055b2cb50e6226c15c6047d6f008a494592d6224a54d7ad1c76fee3

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

module Ripsum
  def ripsum(standard, variance=0)
    lorem = library
    text = []

    lorem_array = lorem.split(' ').shuffle

    while standard > lorem_array.length
      lorem_array.concat(lorem_array.shuffle)
    end

    if variance != 0
      min = standard - (standard * variance)
      max = standard + (standard * variance)
      word_count = rand(min..max).floor
    else
      word_count = standard
    end

    1..word_count.times do |i|
      if i == 0
        text << lorem_array[i].capitalize
      else
        text << lorem_array[i]
      end
    end

    return text.join(' ')
  end

  private

  def library
    Ripsum.configuration.library
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ripsum-0.1.3 lib/ripsum/ripsum_helper.rb