class OpenEHR::RM::DataTypes::Quantity::DvAbsoluteQuantity
Attributes
accuracy[RW]
Public Class Methods
new(args = {})
click to toggle source
Calls superclass method
OpenEHR::RM::DataTypes::Quantity::DvQuantified::new
# File lib/openehr/rm/data_types/quantity.rb, line 149 def initialize(args = {}) super(args) self.accuracy = args[:accuracy] end
Public Instance Methods
add(a_diff)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 154 def add(a_diff) type_check(a_diff) return result_builder(self.class, @magnitude+a_diff.magnitude) end
diff(other)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 160 def diff(other) type_check(other) return result_builder(self.class, (@magnitude-other.magnitude).abs) end
subtract(a_diff)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 166 def subtract(a_diff) type_check(a_diff) return result_builder(self.class, @magnitude-a_diff.magnitude) end
Private Instance Methods
result_builder(klass, magnitude)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 178 def result_builder(klass, magnitude) return klass.new(:magnitude => magnitude, :magnitude_status => @magnitude_status, :accuracy => @accuracy, :accuracy_percent => @accuracy_percent, :normal_range => @normal_range, :normal_status => @normal_status, :other_reference_ranges => @other_reference_ranges) end
type_check(other)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 172 def type_check(other) unless self.is_strictly_comparable_to? other raise ArgumentError, 'type mismatch' end end