Class: OpenEHR::RM::DataTypes::Quantity::DvAmount
- Inherits:
-
DvQuantified
- Object
- Basic::DataValue
- DvOrdered
- DvQuantified
- OpenEHR::RM::DataTypes::Quantity::DvAmount
- Defined in:
- lib/open_ehr/rm/data_types/quantity.rb
Direct Known Subclasses
Constant Summary
Constants included from Support::Definition::BasicDefinition
Support::Definition::BasicDefinition::CR, Support::Definition::BasicDefinition::LF
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
readonly
Returns the value of attribute accuracy.
-
#accuracy_percent ⇒ Object
readonly
Returns the value of attribute accuracy_percent.
Attributes inherited from DvQuantified
Attributes inherited from DvOrdered
#normal_range, #normal_status, #other_refference_ranges
Attributes inherited from Basic::DataValue
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #accuracy_is_percent? ⇒ Boolean
-
#initialize(args = {}) ⇒ DvAmount
constructor
A new instance of DvAmount.
- #set_accuracy(accuracy, accuracy_percent) ⇒ Object
Methods inherited from DvQuantified
#<=>, #accuracy_unknown?, valid_magnitude_status?
Methods inherited from DvOrdered
#<=>, #is_normal?, #is_simple?, #is_strictly_comparable_to?, #other_reference_ranges=
Methods inherited from Basic::DataValue
Constructor Details
#initialize(args = {}) ⇒ DvAmount
Returns a new instance of DvAmount.
194 195 196 197 198 199 200 201 |
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 194 def initialize(args = {}) super(args) unless args[:accuracy].nil? set_accuracy(args[:accuracy], args[:accuracy_percent]) else @accuracy, @accuracy_percent = nil, nil end end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
Returns the value of attribute accuracy.
192 193 194 |
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 192 def accuracy @accuracy end |
#accuracy_percent ⇒ Object (readonly)
Returns the value of attribute accuracy_percent.
192 193 194 |
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 192 def accuracy_percent @accuracy_percent end |
Instance Method Details
#+(other) ⇒ Object
203 204 205 206 207 208 209 210 |
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 203 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) ⇒ Object
212 213 214 215 |
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 212 def -(other) other.magnitude = - other.magnitude self+(other) end |
#accuracy_is_percent? ⇒ Boolean
226 227 228 |
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 226 def accuracy_is_percent? return @accuracy_percent end |
#set_accuracy(accuracy, accuracy_percent) ⇒ Object
217 218 219 220 221 222 223 224 |
# File 'lib/open_ehr/rm/data_types/quantity.rb', line 217 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 |