class CKEditor5::Rails::Semver

def <=>(other)

def <=>(other)
  return nil unless other.is_a?(Semver)
  [major, minor, patch] <=> [other.major, other.minor, other.patch]
end

def initialize(version_string)

def initialize(version_string)
  validate!(version_string)
  @major, @minor, @patch = version_string.split('.').map(&:to_i)
end

def safe_update?(other_version)

def safe_update?(other_version)
  other = self.class.new(other_version)
  return false if other.major != major
  return true if other.minor > minor
  return true if other.minor == minor && other.patch > patch
  false
end

def validate!(version_string)

def validate!(version_string)
  return if version_string.is_a?(String) && version_string.match?(SEMVER_PATTERN)
  raise ArgumentError, 'invalid version format'
end

def version

def version
  "#{major}.#{minor}.#{patch}"
end