Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created April 22, 2013 15:38
Show Gist options
  • Save burtlo/5436094 to your computer and use it in GitHub Desktop.
Save burtlo/5436094 to your computer and use it in GitHub Desktop.
class Allergies
def initialize(score)
@score = score
end
attr_reader :score
def allergens
[ "eggs", "peanuts" ]
end
def list
current_list = []
allergens.each_with_index do |allergen,index|
if score & (2 ** index) > 0
current_list << allergen
end
end
current_list
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment