Class: ProjectVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/iron_hammer/tasks/version.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#buildObject

Returns the value of attribute build.



7
8
9
# File 'lib/iron_hammer/tasks/version.rb', line 7

def build
  @build
end

#majorObject

Returns the value of attribute major.



4
5
6
# File 'lib/iron_hammer/tasks/version.rb', line 4

def major
  @major
end

#minorObject

Returns the value of attribute minor.



5
6
7
# File 'lib/iron_hammer/tasks/version.rb', line 5

def minor
  @minor
end

#revisionObject

Returns the value of attribute revision.



6
7
8
# File 'lib/iron_hammer/tasks/version.rb', line 6

def revision
  @revision
end

Class Method Details

.greatest_from(projects) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/iron_hammer/tasks/version.rb', line 26

def self.greatest_from projects
  greatest = parse '1.0.0.0'
   projects.each do |project|
     current = parse project.version
     greatest = current if current > greatest
   end
   greatest
end

.parse(v) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/iron_hammer/tasks/version.rb', line 9

def self.parse v
	splitted = v.split '.'
	version = ProjectVersion.new
	version.major = splitted[0].to_i
	version.minor = splitted[1].to_i
	version.revision = splitted[2].to_i
	version.build = splitted[3].to_i
	version
end

Instance Method Details

#<=>(other) ⇒ Object



19
20
21
22
23
24
# File 'lib/iron_hammer/tasks/version.rb', line 19

def <=> other
  return @major <=> other.major unless @major == other.major
  return @minor <=> other.minor unless @minor == other.minor
  return @revision <=> other.revision unless @revision == other.revision
  return @build <=> other.build
end

#to_sObject



35
36
37
# File 'lib/iron_hammer/tasks/version.rb', line 35

def to_s
	"#{@major}.#{@minor}.#{@revision}.#{@build}"
end