Sha256: e01cf294591b2728620f5721c3b47e190b4fcd1041b476aa1b95ade16ee9d4bd
Contents?: true
Size: 662 Bytes
Versions: 211
Compression:
Stored size: 662 Bytes
Contents
import Allergen.Allergen object Allergies { private lazy val allergenList = Allergen.values def isAllergicTo(allergen: Allergen, score: Int): Boolean = (allergen.id & score) != 0 def allergies(score: Int): List[Allergen] = allergenList.filter(a => isAllergicTo(a, score)).toList } object Allergen extends Enumeration { type Allergen = Value val Eggs = Value(1, "Eggs") val Peanuts = Value(2, "Peanuts") val Shellfish = Value(4, "Shellfish") val Strawberries = Value(8, "Strawberries") val Tomatoes = Value(16, "Tomatoes") val Chocolate = Value(32, "Chocolate") val Pollen = Value(64, "Pollen") val Cats = Value(128, "Cats") }
Version data entries
211 entries across 211 versions & 1 rubygems