Class: Dor::VersionTag
- Inherits:
-
Object
- Object
- Dor::VersionTag
- Includes:
- Comparable
- Defined in:
- lib/dor/datastreams/version_metadata_ds.rb
Instance Attribute Summary collapse
-
#admin ⇒ Object
readonly
Returns the value of attribute admin.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #increment(sig) ⇒ Object
-
#initialize(maj, min, adm) ⇒ VersionTag
constructor
A new instance of VersionTag.
- #to_s ⇒ Object
Constructor Details
#initialize(maj, min, adm) ⇒ VersionTag
Returns a new instance of VersionTag.
21 22 23 24 25 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 21 def initialize(maj, min, adm) @major = maj.to_i @minor = min.to_i @admin = adm.to_i end |
Instance Attribute Details
#admin ⇒ Object (readonly)
Returns the value of attribute admin.
5 6 7 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 5 def admin @admin end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
5 6 7 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 5 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
5 6 7 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 5 def minor @minor end |
Class Method Details
.parse(raw_tag) ⇒ Object
16 17 18 19 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 16 def self.parse(raw_tag) return nil unless raw_tag =~ /(\d+)\.(\d+)\.(\d+)/ VersionTag.new $1, $2, $3 end |
Instance Method Details
#<=>(other) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 7 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) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 29 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 ⇒ Object
44 45 46 |
# File 'lib/dor/datastreams/version_metadata_ds.rb', line 44 def to_s "#{@major}.#{@minor}.#{admin}" end |