Sha256: 730721a2936dee9e8391cba5cb0935bdfef959962870038cf4bb4eb68eeb7564

Contents?: true

Size: 813 Bytes

Versions: 135

Compression:

Stored size: 813 Bytes

Contents

class Version
  include Comparable

  attr_reader :major, :feature_group, :feature, :bugfix

  def initialize(version="")
    v = version.split(".")
    @major = v[0].to_i
    @feature_group = v[1] ? v[1].to_i : 0
    @feature = v[2] ? v[2].to_i : 0
    @bugfix = v[2] ? v[3].to_i : 0
  end
  
  def <=>(other)
    return @major <=> other.major if ((@major <=> other.major) != 0)
    return @feature_group <=> other.feature_group if ((@feature_group <=> other.feature_group) != 0)
    return @feature <=> other.feature if ((@feature <=> other.feature) != 0)
    return @bugfix <=> other.bugfix
  end
  def self.sort
    self.sort!{|a,b| a <=> b}
  end

  def to_s
    @major.to_s + "." + @feature_group.to_s + "." + @feature.to_s + "." + @bugfix.to_s
  end

	def inspect
		"#{self.class}.new('#{to_s}')"
	end
end

Version data entries

135 entries across 135 versions & 1 rubygems

Version Path
coderunner-0.14.10 lib/coderunner/version.rb
coderunner-0.14.9 lib/coderunner/version.rb
coderunner-0.14.8 lib/coderunner/version.rb
coderunner-0.14.7 lib/coderunner/version.rb
coderunner-0.14.6 lib/coderunner/version.rb
coderunner-0.14.5 lib/coderunner/version.rb
coderunner-0.14.4 lib/coderunner/version.rb
coderunner-0.14.3 lib/coderunner/version.rb
coderunner-0.14.2 lib/coderunner/version.rb
coderunner-0.14.1 lib/coderunner/version.rb
coderunner-0.14.0 lib/coderunner/version.rb
coderunner-0.13.32 lib/coderunner/version.rb
coderunner-0.13.31 lib/coderunner/version.rb
coderunner-0.13.30 lib/coderunner/version.rb
coderunner-0.13.29 lib/coderunner/version.rb
coderunner-0.13.28 lib/coderunner/version.rb
coderunner-0.13.27 lib/coderunner/version.rb
coderunner-0.13.26 lib/coderunner/version.rb
coderunner-0.13.25 lib/coderunner/version.rb
coderunner-0.13.24 lib/coderunner/version.rb