Class: FlirtChecker::Blood
- Inherits:
-
Object
- Object
- FlirtChecker::Blood
- Defined in:
- lib/flirt_checker/blood.rb
Constant Summary collapse
- BLOOD_GROUP =
{ a: ["A","A","A","O"], b: ["B","B","B","O"], o: ["O","O"], ab: ["A","B"] }
Instance Attribute Summary collapse
-
#female ⇒ Object
Returns the value of attribute female.
-
#genotype ⇒ Object
Returns the value of attribute genotype.
-
#male ⇒ Object
Returns the value of attribute male.
Instance Method Summary collapse
- #combo ⇒ Object
- #combo_with_rate ⇒ Object
-
#initialize(male, female, genotype: false) ⇒ Blood
constructor
A new instance of Blood.
Constructor Details
#initialize(male, female, genotype: false) ⇒ Blood
Returns a new instance of Blood.
23 24 25 26 27 |
# File 'lib/flirt_checker/blood.rb', line 23 def initialize(male, female, genotype: false) @male = male @female = female @genotype = genotype end |
Instance Attribute Details
#female ⇒ Object
Returns the value of attribute female.
21 22 23 |
# File 'lib/flirt_checker/blood.rb', line 21 def female @female end |
#genotype ⇒ Object
Returns the value of attribute genotype.
21 22 23 |
# File 'lib/flirt_checker/blood.rb', line 21 def genotype @genotype end |
#male ⇒ Object
Returns the value of attribute male.
21 22 23 |
# File 'lib/flirt_checker/blood.rb', line 21 def male @male end |
Instance Method Details
#combo ⇒ Object
37 38 39 |
# File 'lib/flirt_checker/blood.rb', line 37 def combo combo_with_rate.keys end |
#combo_with_rate ⇒ Object
41 42 43 44 45 |
# File 'lib/flirt_checker/blood.rb', line 41 def combo_with_rate c = combination hash = c.reduce(Hash.new(0)){ |h,v| h[@genotype ? v : v.to_phenotype] += 1; h } hash.each_with_object({}) { |(k,v), h| h[k] = v.to_f / c.size } end |