Sha256: 8a743f1d36322074802c2c11374edd31c6ddf454660fcc59f6670a30568edc1a

Contents?: true

Size: 785 Bytes

Versions: 14

Compression:

Stored size: 785 Bytes

Contents

module Doc
  class Configurator
    class Ruby
      class VersionSpecifier
        attr_reader :str, :parts
        alias_method :to_s, :str
        def initialize(o)
          @str = o.to_s
          @parts = str.scan(/\d+/).map(&:to_i)
        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
        end

        include Comparable
        def <=>(other)
          parts <=> other.parts
        end

        def ===(other)
          if other.respond_to?(:parts)
            parts == other.parts[0, parts.length]
          else
            str === other
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
doc-0.4.1 lib/doc/configurator/ruby/version_specifier.rb
doc-0.4.0 lib/doc/configurator/ruby/version_specifier.rb
doc-0.3.0 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.8 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.7 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.6 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.5 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.4 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.3 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.2 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.1 lib/doc/configurator/ruby/version_specifier.rb
doc-0.2.0 lib/doc/configurator/ruby/version_specifier.rb
doc-0.1.0 lib/doc/configurator/ruby/version_specifier.rb
doc-0.0.1 lib/doc/configurator/ruby/version_specifier.rb