Sha256: 63d568a2d88a2cbf8d7865366f3251f5b0b5a717e90c0feb5dbdf7574208d75e

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

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

  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.beta1 lib/adhearsion/version.rb