Class: ProjectVersion
- Inherits:
-
Object
- Object
- ProjectVersion
- Includes:
- Comparable
- Defined in:
- lib/iron_hammer/tasks/version.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
Returns the value of attribute build.
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#revision ⇒ Object
Returns the value of attribute revision.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#build ⇒ Object
Returns the value of attribute build.
7 8 9 |
# File 'lib/iron_hammer/tasks/version.rb', line 7 def build @build end |
#major ⇒ Object
Returns the value of attribute major.
4 5 6 |
# File 'lib/iron_hammer/tasks/version.rb', line 4 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
5 6 7 |
# File 'lib/iron_hammer/tasks/version.rb', line 5 def minor @minor end |
#revision ⇒ Object
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_s ⇒ Object
35 36 37 |
# File 'lib/iron_hammer/tasks/version.rb', line 35 def to_s "#{@major}.#{@minor}.#{@revision}.#{@build}" end |