probability/rarity.rb
#requests user input regarding the color traits of the release run
#use of "to_i" renders a blank input as "0"
requests user input regarding the color traits of the release run
use of "to_i" renders a blank input as "0"
requests user input regarding the color traits of the release run use of " to_i " renders a blank input as " 0 "
def user_input
puts "\nPlease enter the quantity of each color:".green 
puts "\nGrey:"
@user_grey = gets.to_i
puts "\nYellow:"
@user_yellow = gets.to_i
puts "\nBlue:"
@user_blue = gets.to_i
puts "\nRed:"
@user_red = gets.to_i
puts "\nGreen:"
@user_green = gets.to_i
@user_total = [@user_grey + @user_yellow + @user_blue + @user_red + @user_green]
@user_int = @user_total.inject(0){|sum,x| sum + x }
if @user_int != 5
  then puts "\nERROR: The inputted quantity must be exactly five. Correct your input and try again. \n ".red 
  user_input
end
if (@var = @user_grey.to_s.include? "0") and @var == true
  then
  @user_grey = 1
end
if (@var = @user_yellow.to_s.include? "0") and @var == true
  then
  @user_yellow = 1
end
if (@var = @user_blue.to_s.include? "0") and @var == true
  then
  @user_blue = 1
end
if (@var = @user_red.to_s.include? "0") and @var == true
  then
  @user_red = 1
end
if (@var = @user_green.to_s.include? "0") and @var == true
  then
  @user_green = 1
end
overall
  end
def user_input puts "\nPlease enter the quantity of each color:" . green puts "\nGrey:" @user_grey = gets . to_i puts "\nYellow:" @user_yellow = gets . to_i puts "\nBlue:" @user_blue = gets . to_i puts "\nRed:" @user_red = gets . to_i puts "\nGreen:" @user_green = gets . to_i @user_total = [ @user_grey + @user_yellow + @user_blue + @user_red + @user_green ] @user_int = @user_total . inject ( 0 ) { | sum , x | sum + x } if @user_int != 5 then puts "\nERROR: The inputted quantity must be exactly five. Correct your input and try again. \n " . red user_input end if ( @var = @user_grey . to_s . include? "0" ) and @var == true then @user_grey = 1 end if ( @var = @user_yellow . to_s . include? "0" ) and @var == true then @user_yellow = 1 end if ( @var = @user_blue . to_s . include? "0" ) and @var == true then @user_blue = 1 end if ( @var = @user_red . to_s . include? "0" ) and @var == true then @user_red = 1 end if ( @var = @user_green . to_s . include? "0" ) and @var == true then @user_green = 1 end overall end
requests user input regarding the color traits of the release run
use of "to_i" renders a blank input as "0"
requests user input regarding the color traits of the release run use of " to_i " renders a blank input as " 0 "
#uses Colorize gem #using inject() to get array total #checks to see if the overall user_input quantity totals five; throws error if it is not. #uses Colorize gem #checking to see if the user_input quantity is zero; if so, it replaces it with a value of 1