Class: Eff::Package::SemanticVersion
- Inherits:
-
Object
- Object
- Eff::Package::SemanticVersion
- Includes:
- Comparable
- Defined in:
- lib/eff/package/semantic_version.rb
Constant Summary collapse
- BASE_PARTS =
i(major minor patch)
- PARTS =
BASE_PARTS + i(release identity)
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version_string) ⇒ SemanticVersion
constructor
A new instance of SemanticVersion.
- #to_h ⇒ Object
Constructor Details
#initialize(version_string) ⇒ SemanticVersion
Returns a new instance of SemanticVersion.
13 14 15 16 |
# File 'lib/eff/package/semantic_version.rb', line 13 def initialize(version_string) @version_string = version_string parse! end |
Instance Method Details
#<=>(other) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/eff/package/semantic_version.rb', line 24 def <=>(other) result = 0 BASE_PARTS.each do |part| result = self.public_send(part).to_i <=> other.public_send(part).to_i break unless result == 0 end result end |
#to_h ⇒ Object
18 19 20 21 22 |
# File 'lib/eff/package/semantic_version.rb', line 18 def to_h Hash[ PARTS.map { |part| [part, send(part)] } ] end |