Skip to content

Instantly share code, notes, and snippets.

@kmandreza
Created June 24, 2012 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmandreza/2981810 to your computer and use it in GitHub Desktop.
Save kmandreza/2981810 to your computer and use it in GitHub Desktop.
Evolution....
#TO CREATE A NEW CLASS
module EvolutionarySkills
def breed_rapidly(howrapid)
puts cross_mate.*(howrapid)
end
end
class SomeNewAnimal < String
include EvolutionarySkills
def initialize(var1,var2)
@var1=var1[0..3]
@var2=var2[-4..-1]
end
def cross_mate
@newspecies = @var1 + @var2
".: #{@newspecies} :.\n"
end
def newspecies
end
def mutate(disease)
if disease == "ebola"
mutated_species = @newspecies.reverse
puts "the #{@newspecies} is now a #{mutated_species}, good luck with that!"
elsif disease == "johns special"
puts "the #{@newspecies} is now DEAD, better luck with that!"
elsif disease == "oleg's suprise"
mutated_species == @newspecies.capitalize
puts "the #{@newspecies} is now a #{mutated_species}, good luck with that!"
else
puts "the disease wasn't an issue, nice work"
end
end
end
class SomeNewDisease < String
attr_accessor :disease
def random_disease(num)
virality = rand(num)
if virality == 1
disease = "ebola"
elsif virality == 2
disease = "johns special"
elsif virality == 3
disease = "oleg's surprise"
else
disease = "you got off easy"
end
end
end
furryanimal = SomeNewAnimal.new("Rhino","Elephant")
furryanimal.breed_rapidly(1)
funkytown = SomeNewDisease.new
world_epidemic = funkytown.random_disease(ARGV[0].to_i)
furryanimal.mutate(world_epidemic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment