Class: GcigCa125::Calculator
- Inherits:
-
Object
- Object
- GcigCa125::Calculator
- Defined in:
- lib/gcig_ca125/calculator.rb
Instance Method Summary collapse
- #add_ca125_test(date, value) ⇒ Object
-
#initialize(rx_date, normal_range = (0..30)) ⇒ Calculator
constructor
A new instance of Calculator.
- #is_evaluable? ⇒ Boolean
- #is_normalised? ⇒ Boolean
- #is_response? ⇒ Boolean
- #result ⇒ Object
- #sort_tests ⇒ Object
Constructor Details
#initialize(rx_date, normal_range = (0..30)) ⇒ Calculator
Returns a new instance of Calculator.
5 6 7 8 9 |
# File 'lib/gcig_ca125/calculator.rb', line 5 def initialize(rx_date, normal_range=(0..30)) @normal_range = normal_range @rx_date = rx_date @tests = [] end |
Instance Method Details
#add_ca125_test(date, value) ⇒ Object
15 16 17 18 |
# File 'lib/gcig_ca125/calculator.rb', line 15 def add_ca125_test(date, value) @tests << [date, value] sort_tests end |
#is_evaluable? ⇒ Boolean
20 21 22 23 |
# File 'lib/gcig_ca125/calculator.rb', line 20 def is_evaluable? @evaluable = (@tests.first[0] <= @rx_date) && (@tests.first[0] >= (@rx_date - 9)) @evaluable = (@tests.first[1] > @normal_range.max * 2) if @evaluable end |
#is_normalised? ⇒ Boolean
33 34 35 36 |
# File 'lib/gcig_ca125/calculator.rb', line 33 def is_normalised? @normalised = find_normalised @normalised.any? end |
#is_response? ⇒ Boolean
25 26 27 28 29 30 31 |
# File 'lib/gcig_ca125/calculator.rb', line 25 def is_response? if is_evaluable? @tests.select { |test| (test[0] > date_of_fall + 28 ) && test[1] < half_of_first }.any? else @response = false end end |
#result ⇒ Object
11 12 13 |
# File 'lib/gcig_ca125/calculator.rb', line 11 def result Result.new is_evaluable?, is_response?, is_normalised? end |
#sort_tests ⇒ Object
38 39 40 |
# File 'lib/gcig_ca125/calculator.rb', line 38 def sort_tests @tests = @tests.sort { |a,b| a[0] <=> b[0] } end |