Class: Dumbo::ExtensionVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/dumbo/extension_version.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version = "") ⇒ ExtensionVersion

Returns a new instance of ExtensionVersion.



7
8
9
# File 'lib/dumbo/extension_version.rb', line 7

def initialize(version="")
  @major, @minor, @patch = version.split(".").map(&:to_i)
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



5
6
7
# File 'lib/dumbo/extension_version.rb', line 5

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



5
6
7
# File 'lib/dumbo/extension_version.rb', line 5

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



5
6
7
# File 'lib/dumbo/extension_version.rb', line 5

def patch
  @patch
end

Class Method Details

.sortObject



17
18
19
# File 'lib/dumbo/extension_version.rb', line 17

def self.sort
  self.sort!{|a,b| a <=> b}
end

Instance Method Details

#<=>(other) ⇒ Object



11
12
13
14
15
# File 'lib/dumbo/extension_version.rb', line 11

def <=>(other)
  return major <=> other.major if ((major <=> other.major) != 0)
  return minor <=> other.minor if ((minor <=> other.minor) != 0)
  return patch <=> other.patch if ((patch <=> other.patch) != 0)
end

#to_sObject



21
22
23
# File 'lib/dumbo/extension_version.rb', line 21

def to_s
  [major,minor,patch].join('.')
end