Last active
December 31, 2015 15:59
-
-
Save Chryus/8010591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Compliment | |
attr_accessor :message, :image, :color | |
COMPLIMENTS = ["You're pretty", "You're super-fantastic!"] | |
IMAGES = ["image1", "image2", image3", "image4"] | |
COLORS = ["#8C727B", "#8CBEB2", "F2EBBF", "#F3B562", "#F76363"] | |
HISTORY = [] | |
def initialize | |
@message = COMPLIMENTS.sample | |
@image = IMAGES.sample | |
@color = COLORS.sample | |
HISTORY << self | |
self.check_duplicates | |
end | |
def self.all | |
HISTORY | |
end | |
def self.check_duplicates | |
while Compliment.all[-2].color == Compliment.all[-1].color | |
self.color = COLORS.sample | |
end | |
return Compliment.all[-1].color | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment