Class: SemanticVersioning::Segment
- Inherits:
-
Object
- Object
- SemanticVersioning::Segment
- Includes:
- Comparable
- Defined in:
- lib/semantic_versioning/segment.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #identifiers ⇒ Object
-
#initialize(input) ⇒ Segment
constructor
A new instance of Segment.
Constructor Details
#initialize(input) ⇒ Segment
Returns a new instance of Segment.
7 8 9 |
# File 'lib/semantic_versioning/segment.rb', line 7 def initialize(input) @input = input end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 20 21 |
# File 'lib/semantic_versioning/segment.rb', line 17 def <=>(other) return nil unless other.is_a?(Segment) scores = scores_vs(other) scores.compact.detect { |s| s.abs == 1 } end |
#identifiers ⇒ Object
11 12 13 14 15 |
# File 'lib/semantic_versioning/segment.rb', line 11 def identifiers return [] if @input.nil? ids = @input.split('.') ids.map! { |id| id.match(/^[0-9]+$/) ? id.to_i : id } end |