class Doc::Configurator::Ruby::VersionSpecifier

Attributes

parts[R]
str[R]
to_s[R]

Public Class Methods

new(o) click to toggle source
# File lib/doc/configurator/ruby/version_specifier.rb, line 7
def initialize(o)
  @str = o.to_s
  @parts = str.scan(/\d+/).map(&:to_i)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/doc/configurator/ruby/version_specifier.rb, line 30
def <=>(other)
  parts <=> other.parts
end
===(other) click to toggle source
# File lib/doc/configurator/ruby/version_specifier.rb, line 34
def ===(other)
  if other.respond_to?(:parts)
    parts == other.parts[0, parts.length]
  else
    str === other
  end
end
dir_name() click to toggle source
# File lib/doc/configurator/ruby/version_specifier.rb, line 24
def dir_name
  fmt = 'ruby' + %w[-%d .%d .%d -p%d].take(parts.length).join('')
  fmt % parts
end
drop() click to toggle source
# File lib/doc/configurator/ruby/version_specifier.rb, line 12
def drop
  self.class.new(parts.drop(1).join('.'))
end
full_version?() click to toggle source
# File lib/doc/configurator/ruby/version_specifier.rb, line 20
def full_version?
  valid? && parts.length == 4
end
valid?() click to toggle source
# File lib/doc/configurator/ruby/version_specifier.rb, line 16
def valid?
  str =~ /^\d+\.\d+(?:\.\d+(?:-p\d+)?)?$/
end