Changeset 274


Ignore:
Timestamp:
Sep 17, 2009, 3:05:00 PM (11 years ago)
Author:
KOBAYASHI, Shinji
Message:

version_tree_id changed test/unit to rspec

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

Legend:

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

    r273 r274  
    316316
    317317        class VersionTreeID
    318           attr_reader :value, :trunk_version, :branch_number, :branch_version
    319 
    320           def initialize(value)
    321             self.value = value
     318          attr_reader :trunk_version, :branch_number, :branch_version
     319
     320          def initialize(args = {})
     321            self.value = args[:value]
    322322          end
    323323
    324324          def value=(value)
    325325            raise ArgumentError, 'value invalid' if value.nil? or value.empty?
    326             @trunk_version = @branch_number = @branch_version = nil
    327326            (trunk_version, branch_number, branch_version) = value.split '.'
    328327            self.trunk_version = trunk_version
     
    331330          end
    332331
    333           def trunk_version=(trunk_version)
    334             raise ArgumentError, 'trunk_version invalid' if trunk_version.nil? and !trunk_version.to_i >= 1
    335             @trunk_version = trunk_version
    336             set_value
    337           end
    338 
    339           def branch_number=(branch_number)
    340             raise ArgumentError, 'branch number invalid' unless branch_number.nil? or branch_number.to_i >= 1
    341             @branch_number = branch_number
    342             set_value
    343           end
    344 
    345           def branch_version=(branch_version)
    346             raise ArgumentError, 'branch version invalid' if (!branch_version.nil? and !( branch_version.to_i >= 1)) or (!branch_version.nil? and @branch_number.nil?)
    347             @branch_version = branch_version
    348             set_value
    349           end
    350           def is_branch?
    351             !@branch_version.nil? and !@branch_number.nil?
    352           end
    353 
    354           def is_first?
    355             trunk_version == '1'
    356           end
    357 
    358           private
    359           def set_value
     332          def value
    360333            @value = trunk_version
    361334            @value = @value + '.' + @branch_number unless @branch_number.nil?
    362335            @value = @value + '.' + @branch_version unless @branch_version.nil?
     336            return @value
     337          end
     338
     339          def trunk_version=(trunk_version)
     340            if trunk_version.nil? || (trunk_version.to_i < 1)
     341              raise ArgumentError, 'trunk_version invalid'
     342            end
     343            @trunk_version = trunk_version
     344          end
     345
     346          def branch_number=(branch_number)
     347            unless branch_number.nil? or branch_number.to_i >= 1
     348              raise ArgumentError, 'branch number invalid'
     349            end
     350            @branch_number = branch_number
     351          end
     352
     353          def branch_version=(branch_version)
     354            if (!branch_version.nil? and !(branch_version.to_i >= 1)) or
     355                (!branch_version.nil? and @branch_number.nil?)
     356              raise ArgumentError, 'branch version invalid'
     357            end
     358            @branch_version = branch_version
     359          end
     360
     361          def is_branch?
     362            !@branch_version.nil? and !@branch_number.nil?
     363          end
     364
     365          def is_first?
     366            trunk_version == '1'
    363367          end
    364368        end
Note: See TracChangeset for help on using the changeset viewer.