Class: Upfluence::Peer::Version::SemanticVersion
- Inherits:
-
Object
- Object
- Upfluence::Peer::Version::SemanticVersion
- Defined in:
- lib/upfluence/peer.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(major:, minor:, patch:, suffix: nil) ⇒ SemanticVersion
constructor
A new instance of SemanticVersion.
- #to_s ⇒ Object
Constructor Details
#initialize(major:, minor:, patch:, suffix: nil) ⇒ SemanticVersion
Returns a new instance of SemanticVersion.
9 10 11 12 13 14 |
# File 'lib/upfluence/peer.rb', line 9 def initialize(major:, minor:, patch:, suffix: nil) @major = major @minor = minor @patch = patch @suffix = suffix end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
7 8 9 |
# File 'lib/upfluence/peer.rb', line 7 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
7 8 9 |
# File 'lib/upfluence/peer.rb', line 7 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
7 8 9 |
# File 'lib/upfluence/peer.rb', line 7 def patch @patch end |
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
7 8 9 |
# File 'lib/upfluence/peer.rb', line 7 def suffix @suffix end |
Class Method Details
.parse(version) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/upfluence/peer.rb', line 24 def parse(version) return nil unless version v, suffix = version.split('-', 2) vs = v.split('.') return nil unless vs.count.eql? 3 SemanticVersion.new( major: vs[0].delete_prefix('v').to_i, minor: vs[1].to_i, patch: vs[2].to_i, suffix: suffix ) end |
Instance Method Details
#to_s ⇒ Object
16 17 18 19 20 21 |
# File 'lib/upfluence/peer.rb', line 16 def to_s v = "v#{@major}.#{@minor}.#{@patch}" v += "-#{@suffix}" if @suffix v end |