class OpenEHR::RM::DataTypes::Quantity::DvAbsoluteQuantity

Attributes

accuracy[RW]

Public Class Methods

new(args = {}) click to toggle source
# File lib/open_ehr/rm/data_types/quantity.rb, line 151
def initialize(args = {})
  super(args)
  self.accuracy = args[:accuracy]
end

Public Instance Methods

add(a_diff) click to toggle source
# File lib/open_ehr/rm/data_types/quantity.rb, line 156
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/open_ehr/rm/data_types/quantity.rb, line 162
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/open_ehr/rm/data_types/quantity.rb, line 168
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/open_ehr/rm/data_types/quantity.rb, line 180
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/open_ehr/rm/data_types/quantity.rb, line 174
def type_check(other)
  unless self.is_strictly_comparable_to? other
    raise ArgumentError, 'type mismatch'
  end
end