Class: Versionifier::Version
- Inherits:
-
Object
- Object
- Versionifier::Version
- Defined in:
- lib/versionifier/version.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#regular ⇒ Object
Returns the value of attribute regular.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #increment(which, quant, options = nil) ⇒ Object
-
#initialize(the_version) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
Constructor Details
#initialize(the_version) ⇒ Version
Returns a new instance of Version.
6 7 8 9 10 11 |
# File 'lib/versionifier/version.rb', line 6 def initialize(the_version) splitted = the_version.split "." @major = splitted[0].to_i @regular = splitted[1].to_i @minor = splitted[2].to_i end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
5 6 7 |
# File 'lib/versionifier/version.rb', line 5 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
5 6 7 |
# File 'lib/versionifier/version.rb', line 5 def minor @minor end |
#regular ⇒ Object
Returns the value of attribute regular.
5 6 7 |
# File 'lib/versionifier/version.rb', line 5 def regular @regular end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 |
# File 'lib/versionifier/version.rb', line 36 def ==(other) return self.eql? other end |
#eql?(other) ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'lib/versionifier/version.rb', line 28 def eql?(other) if other.is_a? String return other == self.to_s else return super other end end |
#increment(which, quant, options = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/versionifier/version.rb', line 13 def increment(which, quant, = nil) new_version = self.clone new_version.send "#{which}=".to_sym, self.send(which) + quant if == :reset case which when :major new_version.regular = 0; new_version.minor = 0 when :regular new_version.minor = 0 end end new_version end |
#to_s ⇒ Object
27 |
# File 'lib/versionifier/version.rb', line 27 def to_s; "#{@major}.#{@regular}.#{@minor}"; end |