class OpenEHR::RM::DataTypes::Quantity::DvAmount
Attributes
accuracy[R]
accuracy_percent[R]
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 192 def initialize(args = {}) super(args) unless args[:accuracy].nil? set_accuracy(args[:accuracy], args[:accuracy_percent]) else @accuracy, @accuracy_percent = nil, nil end end
Public Instance Methods
+(other)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 201 def +(other) unless self.is_strictly_comparable_to? other raise ArgumentError, 'type mismatch' end result = self.dup result.magnitude = @magnitude + other.magnitude return result end
-(other)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 210 def -(other) other.magnitude = - other.magnitude self+(other) end
accuracy_is_percent?()
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 224 def accuracy_is_percent? return @accuracy_percent end
set_accuracy(accuracy, accuracy_percent)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 215 def set_accuracy(accuracy, accuracy_percent) if accuracy_percent raise ArgumentError, 'accuracy invalid' if accuracy < 0.0 || accuracy > 100.0 else raise ArgumentError, 'accuracy invaild' if accuracy < 0.0 || accuracy > 1.0 end @accuracy, @accuracy_percent = accuracy, accuracy_percent end