Class: BuildrDependencyExtensions::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/buildr-dependency-extensions/helper.rb

Overview

Parses the version string and provides a natural ordering for versions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_string) ⇒ Version

Returns a new instance of Version.



61
62
63
64
# File 'lib/buildr-dependency-extensions/helper.rb', line 61

def initialize version_string
  @version_string = version_string
  @version_array = version_string.split('.')
end

Instance Attribute Details

#version_arrayObject (readonly)

Returns the value of attribute version_array.



59
60
61
# File 'lib/buildr-dependency-extensions/helper.rb', line 59

def version_array
  @version_array
end

#version_stringObject (readonly)

Returns the value of attribute version_string.



59
60
61
# File 'lib/buildr-dependency-extensions/helper.rb', line 59

def version_string
  @version_string
end

Instance Method Details

#<=>(other_version) ⇒ Object



66
67
68
# File 'lib/buildr-dependency-extensions/helper.rb', line 66

def <=> other_version
  @version_array <=> other_version.version_array
end

#hashObject



72
73
74
# File 'lib/buildr-dependency-extensions/helper.rb', line 72

def hash
  @version_string.hash
end

#to_sObject



76
77
78
# File 'lib/buildr-dependency-extensions/helper.rb', line 76

def to_s
  @version_string
end