Ignore:
Timestamp:
Jun 23, 2009, 8:00:51 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

ref #50
DV_Amount finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/models/rm/data_types/quantity.rb

    r144 r145  
    5656
    5757        class DV_Quantified < DV_Ordered
    58           attr_reader :magnitude, :accuracy, :magnitude_status
     58          attr_reader :magnitude, :magnitude_status, :accuracy
    5959
    6060          def initialize(magnitude, magnitude_status=nil,
     
    165165
    166166        class DV_Amount < DV_Quantified
    167           attr_reader :accuracy, :accuracy_is_percent
    168 
    169           def infix(dv_amount, op)
    170             raise NotImplementError, 'infix must be implemented'
    171           end
    172          
    173           def accuracy=(accuracy)
    174             raise ArgumentError, 'accuracy invalid'
     167          attr_reader :accuracy_is_percent
     168          def initialize(magnitude, magnitude_status=nil, accuracy=nil,
     169                         accuracy_percent=nil, normal_range=nil,
     170                         normal_status = nil, other_reference_ranges=nil)
     171            super(magnitude, magnitude_status, normal_range,
     172                  normal_status, other_reference_ranges)
     173            set_accuracy(accuracy, accuracy_percent) unless accuracy.nil?
     174          end
     175          def +(other)
     176            raise NotImplementError, '+ operator must be overloaded'
     177          end
     178
     179          def -(other)
     180            raise NotImplementError, '- operator must be overloaded'
     181          end
     182
     183          def set_accuracy(accuracy, accuracy_percent)
     184            if accuracy_percent
     185              raise ArgumentError, 'accuracy invalid' if accuracy < 0.0 || accuracy > 100.0
     186            else
     187              raise ArgumentError, 'accuracy invaild' if accuracy < 0.0 || accuracy > 1.0
     188            end
     189            @accuracy, @accuracy_percent = accuracy, accuracy_percent
     190          end
     191
     192          def accuracy_is_percent?
     193            return @accuracy_percent
    175194          end
    176195        end
Note: See TracChangeset for help on using the changeset viewer.