Class: OpenEHR::RM::DataTypes::Quantity::DvProportion

Inherits:
DvAmount show all
Includes:
ProportionKind
Defined in:
lib/open_ehr/rm/data_types/quantity.rb

Overview

end of ProportionKind

Constant Summary

Constants included from ProportionKind

ProportionKind::PK_FRACTION, ProportionKind::PK_INTEGER_FRACTION, ProportionKind::PK_PERCENT, ProportionKind::PK_RATIO, ProportionKind::PK_UNITARY

Constants included from Support::Definition::BasicDefinition

Support::Definition::BasicDefinition::CR, Support::Definition::BasicDefinition::LF

Instance Attribute Summary collapse

Attributes inherited from DvAmount

#accuracy, #accuracy_percent

Attributes inherited from DvQuantified

#magnitude_status

Attributes inherited from DvOrdered

#normal_range, #normal_status, #other_refference_ranges

Attributes inherited from Basic::DataValue

#value

Instance Method Summary collapse

Methods included from ProportionKind

valid_proportion_kind?

Methods inherited from DvAmount

#+, #-, #accuracy_is_percent?, #set_accuracy

Methods inherited from DvQuantified

#<=>, #accuracy_unknown?, valid_magnitude_status?

Methods inherited from DvOrdered

#<=>, #is_normal?, #is_simple?, #other_reference_ranges=

Methods inherited from Basic::DataValue

#==

Constructor Details

#initialize(args = {}) ⇒ DvProportion

Returns a new instance of DvProportion.



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 320

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

Instance Attribute Details

#denominatorObject

Returns the value of attribute denominator.



318
319
320
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 318

def denominator
  @denominator
end

#numeratorObject

Returns the value of attribute numerator.



318
319
320
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 318

def numerator
  @numerator
end

#precisionObject

Returns the value of attribute precision.



318
319
320
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 318

def precision
  @precision
end

#typeObject

Returns the value of attribute type.



318
319
320
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 318

def type
  @type
end

Instance Method Details

#is_integral?Boolean

Returns:

  • (Boolean)


384
385
386
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 384

def is_integral?
  return denominator.integer? && numerator.integer?
end

#is_strictly_comparable_to?(other) ⇒ Boolean

Returns:

  • (Boolean)


388
389
390
391
392
393
394
395
396
397
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 388

def is_strictly_comparable_to?(other)
  unless super(other)
    return false
  end
  if other.type == @type
    return true
  else
    return false
  end
end

#magnitudeObject



371
372
373
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 371

def magnitude
  return numerator.to_f/denominator.to_f
end