Sha256: 449c5a49dcdc9096c4e52557ffc6edd9fec00656d4a1fe8bd06df0430bf0a8dc

Contents?: true

Size: 977 Bytes

Versions: 14

Compression:

Stored size: 977 Bytes

Contents

module RD
  class Version
    attr_reader :name
    attr_reader :major, :minor, :patch_level

    def Version.new_from_version_string(name, version_str)
      major, minor, patch_level, *dummy = analyze_version_string(version_str)
      return Version.new(name, major, minor, patch_level)
    end
    
    def initialize(name, major, minor, patch_level)
      @name = name
      @major = major
      @minor = minor
      @patch_level = patch_level
    end

    def Version.analyze_version_string(version_str)
      version_str = clean_up_version_string(version_str)
      version_str.split(/\./).collect{|i| i.to_i }
    end

    def to_s
      result = sprintf("%s %d", @name, @major)
      result += sprintf(".%d", @minor) if @minor
      result += sprintf(".%d", @patch_level) if @patch_level
      result
    end

    def Version.clean_up_version_string(version_str)
      if /^\$Version:?\s*(.*)\$/ === version_str
	$1
      else
	version_str
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
nishidayuya-rd2odt-0.1.1.20090701.01 lib/rd2odt/rdtool/rd/version.rb
nishidayuya-rd2odt-0.1.1.20090704.01 lib/rd2odt/rdtool/rd/version.rb
nishidayuya-rd2odt-0.1.1.20090706.01 lib/rd2odt/rdtool/rd/version.rb
nishidayuya-rd2odt-0.1.1 lib/rd2odt/rdtool/rd/version.rb
rdtool-0.6.31 lib/rd/version.rb
rdtool-0.6.30 lib/rd/version.rb
rdtool-0.6.29 lib/rd/version.rb
rdtool-0.6.28 lib/rd/version.rb
rdtool-0.6.27 lib/rd/version.rb
rdtool-0.6.26 lib/rd/version.rb
rdtool-0.6.25 lib/rd/version.rb
rdtool-0.6.23 lib/rd/version.rb
rd2odt-0.1.1 lib/rd2odt/rdtool/rd/version.rb
rd2odt-0.1.0 lib/rd2odt/rdtool/rd/version.rb