pkg_version: delegate major, minor, patch methods to :version

This commit is contained in:
Seeker 2020-08-11 13:01:54 -07:00
parent 266a944bb5
commit 51bc9ae3d9

View File

@ -4,11 +4,20 @@ require "version"
class PkgVersion
include Comparable
extend Forwardable
RX = /\A(.+?)(?:_(\d+))?\z/.freeze
attr_reader :version, :revision
delegate [
:major,
:minor,
:patch,
:major_minor,
:major_minor_patch,
] => :version
def self.parse(path)
_, version, revision = *path.match(RX)
version = Version.create(version)