class VersionRecord::Version::Parser

Constants

VERSION_PATTERN

Public Class Methods

new(version) click to toggle source
# File lib/version_record/version.rb, line 90
def initialize(version)
  @version = version
end

Public Instance Methods

parse() click to toggle source
# File lib/version_record/version.rb, line 94
def parse
  error! unless match = @version.match(VERSION_PATTERN)
  prerelease = Prerelease.new(match[4]) if match[4].present?

  [match[1].to_i, match[2].to_i, match[3].to_i, prerelease]
end

Private Instance Methods

error!() click to toggle source
# File lib/version_record/version.rb, line 103
def error!
  raise ArgumentError, "Malformed version number string #{@version}"
end