Changeset 273 for ruby/branches


Ignore:
Timestamp:
Sep 17, 2009, 1:34:07 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

uid_based_id family changed test/unit to rspec

Location:
ruby/branches/0.5
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/rm/support/identification.rb

    r272 r273  
    213213
    214214        class UIDBasedID < ObjectID
    215           def initialize(value)
     215          attr_reader :root, :extension
     216
     217          def initialize(args = {})
     218            super(args)
     219          end
     220
     221          def value=(value)
    216222            super(value)
    217           end
    218 
    219           def extension
    220             if self.has_extension?
    221               @value[/::.*/][2..-1]
    222             else
    223               ''
     223            if /(\S+)::(\S+)/ =~ value
     224              @root = UID.new(:value => $1)
     225              @extension = $2
     226            else
     227              @root = UID.new(:value => value)
     228              @extension = ''
    224229            end
    225230          end
    226231
    227232          def has_extension?
    228             @value.include? '::'
    229           end
    230 
    231           def root
    232             if self.has_extension?
    233               @value[/.*::/][0..-3]
    234             else
    235               @value
    236             end
     233            return !@extension.empty?
    237234          end
    238235        end
  • ruby/branches/0.5/spec/lib/open_ehr/rm/support/identification/uid_spec.rb

    r272 r273  
    44describe UID do
    55  before(:each) do
    6     @uid = UID.new('1001')
     6    @uid = UID.new(:value => '1001')
    77  end
    88
Note: See TracChangeset for help on using the changeset viewer.