class MyPrecious::FinalVersion
Represents the “final” part of a PEP-440 version string
Public Class Methods
new(final_ver)
click to toggle source
# File lib/myprecious/python_packages.rb, line 688 def initialize(final_ver) @value = case final_ver when Array then final_ver else final_ver.split('.').map {|s| seg_value(s)} end end
Public Instance Methods
<=>(rhs)
click to toggle source
# File lib/myprecious/python_packages.rb, line 716 def <=>(rhs) nil unless rhs.kind_of?(FinalVersion) (0..Float::INFINITY).lazy.each do |i| return 0 if self[i].nil? && rhs[i].nil? return 0 if [self[i], rhs[i]].include?(:*) diff = (self[i] || 0) <=> (rhs[i] || 0) return diff if diff != 0 end end
[](n)
click to toggle source
# File lib/myprecious/python_packages.rb, line 695 def [](n) @value[n] end
each(&blk)
click to toggle source
# File lib/myprecious/python_packages.rb, line 703 def each(&blk) @value.each(&blk) end
inspect()
click to toggle source
# File lib/myprecious/python_packages.rb, line 712 def inspect "#<#{self.class.name} #{to_s}>" end
length()
click to toggle source
# File lib/myprecious/python_packages.rb, line 699 def length @value.length end
to_s()
click to toggle source
# File lib/myprecious/python_packages.rb, line 708 def to_s @value.join('.') end
to_series()
click to toggle source
# File lib/myprecious/python_packages.rb, line 727 def to_series self.class.new(@value.dup.tap do |mver| mver[-1] = :* end.join('.')) end
Private Instance Methods
seg_value(s)
click to toggle source
# File lib/myprecious/python_packages.rb, line 734 def seg_value(s) if s == '*' :* else s.to_i end end