class OpenEHR::RM::DataTypes::Quantity::DvProportion
Attributes
denominator[R]
numerator[R]
precision[R]
type[R]
Public Class Methods
new(args = {})
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 318 def initialize(args = {}) self.type = args[:type] self.numerator = args[:numerator] self.denominator = args[:denominator] self.precision = args[:precision] self.magnitude_status =args[:magnitude_status] unless args[:accuracy].nil? set_accuracy(args[:accuracy], args[:accuracy_percent]) else @accuracy, @accuracy_percent = nil, nil end self.normal_range = args[:normal_range] self.normal_status = args[:normal_status] self.other_reference_ranges = args[:other_reference_ranges] end
Public Instance Methods
denominator=(denominator)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 343 def denominator=(denominator) case @type when PK_UNITARY unless denominator == 1 raise ArgumentError, 'Unitary denominator must be 1' end when PK_PERCENT unless denominator == 100 raise ArgumentError, 'Percent denominator must be 100' end when PK_FRACTION, PK_INTEGER_FRACTION unless denominator.integer? and @numerator.integer? raise ArgumentError, 'Fraction numerator/denominator must be integer' end end @denominator = denominator end
is_integral?()
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 382 def is_integral? return denominator.integer? && numerator.integer? end
is_strictly_comparable_to?(other)
click to toggle source
Calls superclass method
OpenEHR::RM::DataTypes::Quantity::DvOrdered#is_strictly_comparable_to?
# File lib/openehr/rm/data_types/quantity.rb, line 386 def is_strictly_comparable_to?(other) unless super(other) return false end if other.type == @type return true else return false end end
magnitude()
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 369 def magnitude return numerator.to_f/denominator.to_f end
numerator=(numerator)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 334 def numerator=(numerator) raise ArgumentError, 'numerator should not be nil' if numerator.nil? if (@type == PK_FRACTION || @type == PK_INTEGER_FRACTION) && !numerator.integer? raise ArgumentError, 'numerator invalid for type' end @numerator = numerator end
precision=(precision)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 373 def precision=(precision) unless precision.nil? if (self.is_integral? && precision !=0) raise ArgumentError, 'precision invalid' end end @precision = precision end
type=(type)
click to toggle source
# File lib/openehr/rm/data_types/quantity.rb, line 361 def type=(type) if ProportionKind.valid_proportion_kind?(type) @type = type else raise ArgumentError, 'type invalid' end end