Class: EpiDocValidator::SemVer
- Inherits:
-
Object
- Object
- EpiDocValidator::SemVer
- Defined in:
- lib/epi_doc_validator/sem_ver.rb
Instance Attribute Summary collapse
-
#semver ⇒ Object
readonly
Returns the value of attribute semver.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(semver) ⇒ SemVer
constructor
A new instance of SemVer.
Constructor Details
#initialize(semver) ⇒ SemVer
Returns a new instance of SemVer.
7 8 9 10 11 12 13 14 15 |
# File 'lib/epi_doc_validator/sem_ver.rb', line 7 def initialize(semver) @semver = semver numbers, @patch = *semver.split('-') if semver.match?(/\A\d/) @components = numbers.split('.').map(&:to_i) end end |
Instance Attribute Details
#semver ⇒ Object (readonly)
Returns the value of attribute semver.
25 26 27 |
# File 'lib/epi_doc_validator/sem_ver.rb', line 25 def semver @semver end |
Class Method Details
.sort(versions) ⇒ Object
3 4 5 |
# File 'lib/epi_doc_validator/sem_ver.rb', line 3 def self.sort(versions) versions.map { |v| new(v) }.sort.map(&:semver) end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/epi_doc_validator/sem_ver.rb', line 17 def <=>(other) return 0 if semver == other.semver return compare_strings(other) if string? || other.string? compare_components(other) end |