lib/doc/configurator/ruby/version_specifier.rb in doc-0.4.1 vs lib/doc/configurator/ruby/version_specifier.rb in doc-0.5.0
- old
+ new
@@ -7,19 +7,24 @@
def initialize(o)
@str = o.to_s
@parts = str.scan(/\d+/).map(&:to_i)
end
+ def drop
+ self.class.new(parts.drop(1).join('.'))
+ end
+
def valid?
str =~ /^\d+\.\d+(?:\.\d+(?:-p\d+)?)?$/
end
def full_version?
valid? && parts.length == 4
end
def dir_name
- 'ruby-%d.%d.%d-p%d' % parts
+ fmt = 'ruby' + %w[-%d .%d .%d -p%d].take(parts.length).join('')
+ fmt % parts
end
include Comparable
def <=>(other)
parts <=> other.parts