Changeset 252
 Timestamp:
 Sep 7, 2009, 8:16:48 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity.rb
r250 r252 313 313 attr_reader :numerator, :denominator, :type, :precision 314 314 315 def initialize(numerator, denominator, type, precision=nil, 316 magnitude_status=nil, accuracy=nil, 317 accuracy_percent=nil, normal_range=nil, 318 normal_status = nil, other_reference_ranges=nil) 319 self.type = type 320 self.numerator = numerator 321 self.denominator = denominator 322 self.precision = precision 323 self.magnitude_status = magnitude_status 324 unless accuracy.nil? 325 set_accuracy(accuracy, accuracy_percent) 315 def initialize(args = {}) 316 self.type = args[:type] 317 self.numerator = args[:numerator] 318 self.denominator = args[:denominator] 319 self.precision = args[:precision] 320 self.magnitude_status =args[:magnitude_status] 321 unless args[:accuracy].nil? 322 set_accuracy(args[:accuracy], args[:accuracy_percent]) 326 323 else 327 324 @accuracy, @accuracy_percent = nil, nil 328 325 end 329 self.normal_range = normal_range330 self.normal_status = normal_status331 self.other_reference_ranges = other_reference_ranges326 self.normal_range = args[:normal_range] 327 self.normal_status = args[:normal_status] 328 self.other_reference_ranges = args[:other_reference_ranges] 332 329 end 333 330 … … 342 339 343 340 def denominator=(denominator) 344 if denominator.nil? or denominator == PK_RATIO 345 raise ArgumentError, 'denominator invalid' 346 end 347 if (@type == PK_FRACTION  @type == PK_INTEGER_FRACTION) && 348 !denominator.integer? 349 raise ArgumentError, 'denominator invalid for type' 350 end 351 if @type == PK_UNITARY && denominator != 1 352 raise ArgumentError, 'denominator invalid for type' 353 end 354 if @type == PK_PERCENT && denominator != 100 355 raise ArgumentError, 'denominator invaild for type' 341 case @type 342 when PK_UNITARY 343 unless denominator == 1 344 raise ArgumentError, 'Unitary denominator must be 1' 345 end 346 when PK_PERCENT 347 unless denominator == 100 348 raise ArgumentError, 'Percent denominator must be 100' 349 end 350 when PK_FRACTION, PK_INTEGER_FRACTION 351 unless denominator.integer? and @numerator.integer? 352 raise ArgumentError, 'Fraction numerator/denominator must be integer' 353 end 356 354 end 357 355 @denominator = denominator … … 372 370 def precision=(precision) 373 371 unless precision.nil? 374 unless precision == 0  self.is_integral? 375 @precision = precision 376 else 372 if (self.is_integral? && precision !=0) 377 373 raise ArgumentError, 'precision invalid' 378 374 end 379 375 end 376 @precision = precision 380 377 end 381 378 … … 385 382 386 383 def is_strictly_comparable_to?(other) 387 unless other.instance_of?(DvProportion)384 unless super(other) 388 385 return false 389 386 end
Note: See TracChangeset
for help on using the changeset viewer.