Sha256: f983aa1daafc059ed67368b2a8a7a5e30933b727dbfd8373e63dd148bdbd62af
Contents?: true
Size: 1.32 KB
Versions: 4
Compression:
Stored size: 1.32 KB
Contents
# Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved. # Author: Nicolas Despres <polrop@lrde.epita.fr>. # License: Gnu General Public License. # $LastChangedBy: polrop $ # $Id: version.rb 101 2005-01-15 07:58:58Z polrop $ class Version include Comparable attr_accessor :major, :minor, :revision def initialize(major, minor, revision) @major = major @minor = minor @revision = revision end def <=>(other) if @major == other.major if @minor == other.minor @revision <=> other.revision else @minor <=> other.minor end else @major <=> other.major end end def to_s "#@major.#@minor.#@revision" end def to_a [ @major, @minor, @revision ] end end # class Version if defined? TEST_MODE or __FILE__ == $0 require 'test/unit/ui/yaml/testrunner' class VersionTest < Test::Unit::TestCase def test_simple assert(Version.new(1, 2, 3) < Version.new(1, 2, 4)) assert(Version.new(1, 2, 4) > Version.new(1, 2, 3)) assert(Version.new(1, 2, 3) == Version.new(1, 2, 3)) assert(Version.new(1, 3, 3) > Version.new(1, 2, 3)) assert(Version.new(1, 2, 3) < Version.new(1, 3, 3)) assert(Version.new(2, 2, 3) > Version.new(1, 2, 3)) assert(Version.new(1, 2, 3) < Version.new(2, 2, 3)) end end # class VersionTest end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
ttk-0.1.576 | ruby_ex/version.rb |
ttk-0.1.579 | ruby_ex/version.rb |
ttk-0.1.580 | ruby_ex/version.rb |
vcs-0.2.148 | ruby_ex/version.rb |