class UniversaTools::SemanticVersion
Attributes
parts[R]
Public Class Methods
new(string)
click to toggle source
# File lib/universa_tools/semantic_version.rb, line 6 def initialize string @parts = string.split('.').map(&:to_i) @parts.any? { |x| x < 0 } and raise ArgumentError, "version numbers must be positive" end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/universa_tools/semantic_version.rb, line 11 def <=> other if other.is_a?(SemanticVersion) n = [@parts.size, other.parts.size].max (0...n).each { |i| my = @parts[i] || -1 his = other.parts[i] || -1 return my <=> his if my != his } 0 else self <=> SemanticVersion.new(other) end end
to_s()
click to toggle source
# File lib/universa_tools/semantic_version.rb, line 25 def to_s @str ||= parts.join('.') end