Changeset 97 for ruby/trunk


Ignore:
Timestamp:
Aug 16, 2008, 6:46:52 PM (16 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #39
locatable_ref class finished

Location:
ruby/trunk/lib/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/models/rm/support/identification.rb

    r95 r97  
    4747          end
    4848        end
    49        
     49
    5050        class Archetype_ID < Object_ID
    5151          attr_reader :domain_concept, :rm_name, :rm_entity, :rm_originator, :specialisation, :version_id
     
    129129            super(value)
    130130          end
     131
    131132          def extension
    132133            if self.has_extension?
     
    136137            end
    137138          end
     139
    138140          def has_extension?
    139141            @value.include? '::'
    140142          end
     143
    141144          def root
    142145            if self.has_extension?
     
    145148              @value
    146149            end
     150          end
     151        end
     152
     153        class Locatable_Ref < Object_Ref
     154          attr_reader :namespace, :type, :id, :path
     155
     156          def initialize(namespace, type, id, path)
     157            super(namespace, type, id)
     158            self.path = path
     159          end
     160
     161          def path=(path)
     162            raise ArgumentError if path.nil? or path.empty?
     163            @path = path
     164          end
     165
     166          def as_uri
     167            'ehr://' + @id.value + '/' + @path
    147168          end
    148169        end
  • ruby/trunk/lib/models/tests/test_reference_model.rb

    r96 r97  
    153153    assert_nothing_raised(Exception){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.3')}
    154154    assert_nothing_raised(Exception){@hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')}
    155     assert_nothing_raised(Exception){@locatable_ref = OpenEHR::RM::Support::Identification::Locatable_Ref.new('unknown', 'PERSON', @uid_based_id, '/data/event[at0001, standing]')}
     155    assert_nothing_raised(Exception){@locatable_ref = OpenEHR::RM::Support::Identification::Locatable_Ref.new('unknown', 'PERSON', @uid_based_id, 'data/event[at0001, standing]')}
    156156  end
    157157 
     
    349349# test constructor function
    350350    assert_equal 'unknown', @locatable_ref.namespace
    351     assert_equal 'PARTY', @locatable_ref.type
     351    assert_equal 'PERSON', @locatable_ref.type
    352352    assert_equal @uid_based_id, @locatable_ref.id
    353     assert_equal '/data/event[at0001, standing]', @locatable_ref.path
    354     assert_equal 'ehr://rrip/data/event[at0001, standing]', @locatable_ref.as_uri
    355 
    356 
     353    assert_equal 'data/event[at0001, standing]', @locatable_ref.path
     354    assert_equal 'ehr://rrip::0.0.3/data/event[at0001, standing]', @locatable_ref.as_uri
     355#test path
     356    assert_nothing_raised(Exception){@locatable_ref.path = 'data/event[at0002, tilting]'}
     357    assert_equal 'data/event[at0002, tilting]', @locatable_ref.path
     358    assert_equal 'ehr://rrip::0.0.3/data/event[at0002, tilting]', @locatable_ref.as_uri
    357359  end
    358360end
Note: See TracChangeset for help on using the changeset viewer.