Class: Pebbles::Git::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/pebbles/git.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major, minor = 0, patch = 0, special = 0) ⇒ Version

Returns a new instance of Version.



53
54
55
# File 'lib/pebbles/git.rb', line 53

def initialize(major, minor=0, patch=0, special=0)
  @major, @minor, @patch, @special = major, minor, patch, special
end

Instance Attribute Details

#majorObject

Returns the value of attribute major.



51
52
53
# File 'lib/pebbles/git.rb', line 51

def major
  @major
end

#minorObject

Returns the value of attribute minor.



51
52
53
# File 'lib/pebbles/git.rb', line 51

def minor
  @minor
end

#patchObject

Returns the value of attribute patch.



51
52
53
# File 'lib/pebbles/git.rb', line 51

def patch
  @patch
end

#specialObject

Returns the value of attribute special.



51
52
53
# File 'lib/pebbles/git.rb', line 51

def special
  @special
end

Class Method Details

.parse(s) ⇒ Object



57
58
59
60
# File 'lib/pebbles/git.rb', line 57

def self.parse(s)
  digits = s.split('.').map { |i| i.to_i }
  Version.new(*digits)
end

Instance Method Details

#<=>(other) ⇒ Object



62
63
64
65
66
67
# File 'lib/pebbles/git.rb', line 62

def <=>(other)
  return major <=> other.major unless (major <=> other.major) == 0
  return minor <=> other.minor unless (minor <=> other.minor) == 0
  return patch <=> other.patch unless (patch <=> other.patch) == 0
  return special <=> other.special
end