linkingpaths-alea gem

Gem details

alea is a tiny gem that aim to bring some aleatory behavior to ruby Kernel.

Websitehttp://github.com/linkingpaths/alea Author Linking Paths, Aitor Garcia Tags kernel, aleatory, alea, load scripts, test scripts, test load, test data, percentage

Documentation

Install the Gem:
gem install linkingpaths-alea
require 'alea'

# Add between 10 and 25 friends to a user
@user.add_friends rand_within(10..25)

# 75% chances of this happens
frequently do
  update_profile(@user) 
end

# 65% chances of this happens
probably do
  @group.activate!
end

# 20% chances of this happens
rarely do
  generate_404
end

# 5% chances of this happens
almost_never do
    grant_admin_privileges(@user)
end

# 95% chances of this happens
almost_always do
  post_incorrect_data_for_captcha
end

# 50% chances of true 
@group.moderated = maybe

# Calculate rounded percents 
send_mail_to 20.percent.of(the_community)


Edit Gem | Back in time (2 older versions) | Last edited by: aitor, about 1 year ago