Sha256: 00dc02a7a053318df5546db3acc48b653728d586b9c9e74e9dbcbaeb716ede62

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module Adhearsion #:nodoc:
  VERSION = '2.0.0.alpha1'

  class PkgVersion
    include Comparable

    attr_reader :major, :minor, :revision

    def initialize(version = nil)
      version ||= ""
      @major, @minor, @revision, @patchlevel = version.split(".", 4).map(&:to_i)
      @major = 0 unless @major
    end

    def <=>(other)
      return @major     <=> other.major     unless (@major <=> other.major) == 0
      return @minor     <=> other.minor     unless (@minor <=> other.minor) == 0
      return @revision  <=> other.revision  unless (@revision <=> other.revision) == 0
      return 0
    end

    def self.sort
      self.sort! { |a,b| a <=> b }
    end

    def to_s
      "#{@major}.#{@minor}.#{@revision}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adhearsion-2.0.0.alpha1 lib/adhearsion/version.rb