Sha256: 4d76a28399067ac7f3f70ef5902bf97005e882f66c11cd0747fea837e310de37

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

# frozen_string_literal: true

require 'rubygems'

module Xezat
  class Cygversion
    def initialize(str)
      matched = str.match(/(.+)-(.+)/)
      version = matched[1]
      @release = matched[2]
      split = version.split('+')
      @version = split[0].tr('_', '.')
      @revision = split.length >= 2 ? split[1].match(/(\d+)/)[0].to_i : Time.at(0).strftime('%Y%m%d').to_i
    end

    def to_v
      [Gem::Version.new(@version), @revision, @release]
    end

    def to_a
      [@version, @revision, @release]
    end

    def <=>(other)
      to_v <=> other.to_v
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xezat-0.2.0 lib/xezat/cygversion.rb
xezat-0.1.2 lib/xezat/cygversion.rb