class Dor::VersionTag
Attributes
admin[R]
major[R]
minor[R]
Public Class Methods
new(maj, min, adm)
click to toggle source
# File lib/dor/datastreams/version_metadata_ds.rb, line 26 def initialize(maj, min, adm) @major = maj.to_i @minor = min.to_i @admin = adm.to_i end
parse(raw_tag)
click to toggle source
@param [String] raw_tag the value of the tag attribute from a Version node
# File lib/dor/datastreams/version_metadata_ds.rb, line 20 def self.parse(raw_tag) return nil unless raw_tag =~ /(\d+)\.(\d+)\.(\d+)/ VersionTag.new $1, $2, $3 end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/dor/datastreams/version_metadata_ds.rb, line 9 def <=>(other) diff = @major <=> other.major return diff if diff != 0 diff = @minor <=> other.minor return diff if diff != 0 @admin <=> other.admin end
increment(sig)
click to toggle source
@param [Symbol] sig which part of the version tag to increment
:major, :minor, :admin
# File lib/dor/datastreams/version_metadata_ds.rb, line 34 def increment(sig) case sig when :major @major += 1 @minor = 0 @admin = 0 when :minor @minor += 1 @admin = 0 when :admin @admin += 1 end self end
to_s()
click to toggle source
# File lib/dor/datastreams/version_metadata_ds.rb, line 49 def to_s "#{@major}.#{@minor}.#{admin}" end