Ignore:
Timestamp:
Aug 27, 2009, 10:47:01 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

moving to Rspec

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb

    r224 r226  
    1010        class TermMapping
    1111          attr_reader :match, :purpose, :target
    12           def initialize(match, purpose, target)
    13             match_valid(match)
    14             purpose_valid(purpose)
    15             target_valid(target)
    16             @match, @purpose, @target = match, purpose, target
     12
     13          def initialize(args ={})
     14            self.match = args[:match]
     15            self.purpose = args[:purpose]
     16            self.target = args[:target]
    1717          end
     18
     19          def match=(match)
     20            unless TermMapping.is_valid_mach_code? match
     21              raise ArgumentError, 'invalid match character'
     22            end
     23            @match = match
     24          end
     25
     26          def purpose=(purpose)
     27#            if !purpose.nil? and !purpose.instance_of?(DvCodedText)
     28#              raise ArgumentError, "purpose is not valid"
     29#            end
     30            # should be settled after terminology service implemented
     31            @purpose = purpose
     32          end
     33
     34          def target=(target)
     35            raise ArgumentError, "target must not be nil" if target.nil?
     36            @target = target
     37          end
     38
    1839          def broader?
    1940            match == '>'
    2041          end
     42
    2143          def equivalent?
    2244            match == '='
    2345          end
     46
    2447          def narrower?
    2548            match == '<'
    2649          end
     50
    2751          def unknown?
    2852            match == '?'
    2953          end
     54
    3055          def TermMapping.is_valid_mach_code?(c)
    3156            c == '>' or c == '=' or c == '<' or c == '?'
    32           end
    33           private
    34           def match_valid(match)
    35             raise ArgumentError, "match is not valid" if !TermMapping.is_valid_mach_code? match
    36           end
    37           def purpose_valid(purpose)
    38             if purpose.nil? or !purpose.instance_of? DvCodedText
    39               raise ArgumentError, "purpose is not valid"
    40             end
    41             # should be settled after terminology service implemented
    42           end
    43           def target_valid(target)
    44             raise ArgumentError, "target must not be nil" if target.nil?
    4557          end
    4658        end
Note: See TracChangeset for help on using the changeset viewer.