Skip to content

Instantly share code, notes, and snippets.

@Chryus
Last active December 31, 2015 15:59
Show Gist options
  • Save Chryus/8010591 to your computer and use it in GitHub Desktop.
Save Chryus/8010591 to your computer and use it in GitHub Desktop.
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