Changeset 248 for ruby/branches/0.5/lib/open_ehr/rm/data_types
- Timestamp:
- Sep 7, 2009, 12:07:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity.rb
r247 r248 43 43 end 44 44 45 def is_strictly_comparable_to?(other) 46 raise NotImplementedError, 'this method should be implemented' 45 def is_strictly_comparable_to?(others) 46 if others.instance_of? self.class 47 return true 48 else 49 return false 50 end 47 51 end 48 52 end … … 113 117 end 114 118 115 def is_strictly_comparable_to?(others)116 unless others.instance_of? OpenEHR::RM::DataTypes::Quantity::DvOrdinal117 return false118 end119 unless others.symbol.defining_code.terminology_id.value ==120 @symbol.defining_code.terminology_id.value121 return false122 end123 return true124 end125 126 119 def <=>(other) 127 120 @value <=> other.value … … 133 126 else 134 127 @limits = limits 128 end 129 end 130 def is_strictly_comparable_to?(others) 131 super 132 unless others.instance_of? self.class 133 return false 134 end 135 unless others.symbol.defining_code.terminology_id.value == 136 @symbol.defining_code.terminology_id.value 137 return false 138 else 139 return true 135 140 end 136 141 end … … 163 168 class DvAmount < DvQuantified 164 169 attr_reader :accuracy, :accuracy_percent 165 def initialize(magnitude, magnitude_status=nil, accuracy=nil, 166 accuracy_percent=nil, normal_range=nil, 167 normal_status = nil, other_reference_ranges=nil) 168 super(magnitude, magnitude_status, normal_range, 169 normal_status, other_reference_ranges) 170 unless accuracy.nil? 171 set_accuracy(accuracy, accuracy_percent) 170 171 def initialize(args = {}) 172 super(args) 173 unless args[:accuracy].nil? 174 set_accuracy(args[:accuracy], args[:accuracy_percent]) 172 175 else 173 176 @accuracy, @accuracy_percent = nil, nil … … 176 179 177 180 def +(other) 178 unless self.is_strictly_comparable_to? (other)181 unless self.is_strictly_comparable_to? other 179 182 raise ArgumentError, 'type mismatch' 180 183 end 181 re turn DvAmount.new(@magnitude+other.magnitude, @magnitude_status,182 @accuracy, @accuracy_percent, @normal_range,183 @normal_status, @other_reference_ranges)184 end 185 186 def -(other) 184 result = self.dup 185 result.magnitude = @magnitude + other.magnitude 186 return result 187 end 188 189 def -(other) 187 190 other.magnitude = - other.magnitude 188 191 self+(other) … … 253 256 254 257 class DvCount < DvAmount 255 def is_strictly_comparable_to?(others) 256 return false if others.nil? 257 if others.instance_of?(DvCount) 258 return true 259 else 260 return false 261 end 262 end 258 263 259 end 264 260
Note:
See TracChangeset
for help on using the changeset viewer.