Sha256: 5dd21ba70307196f43d8af66c71fe93dc885b15656b8728c65b6eed200d10fd9

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

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

    min = standard - (standard * variance)
    max = standard + (standard * variance)
    lorem_array = lorem.split(' ').shuffle

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

    random_number = rand(min..max).floor

    1..random_number.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.2 lib/ripsum/ripsum_helper.rb