class Bundler::RubyVersion

def self.system

def self.system
  ruby_engine = if defined?(RUBY_ENGINE) && !RUBY_ENGINE.nil?
    RUBY_ENGINE.dup
  else
    # not defined in ruby 1.8.7
    "ruby"
  end
  ruby_engine_version = case ruby_engine
                        when "ruby"
                          RUBY_VERSION.dup
                        when "rbx"
                          Rubinius::VERSION.dup
                        when "jruby"
                          JRUBY_VERSION.dup
                        else
                          raise BundlerError, "RUBY_ENGINE value #{RUBY_ENGINE} is not recognized"
  end
  @ruby_version ||= RubyVersion.new(RUBY_VERSION.dup, RUBY_PATCHLEVEL.to_s, ruby_engine, ruby_engine_version)
end

def ==(other)

def ==(other)
  versions == other.versions &&
    engine == other.engine &&
    engine_versions == other.engine_versions &&
    patchlevel == other.patchlevel
end

def diff(other)

3. engine_version
2. ruby_version
1. engine
The priority of attributes are
[diff, this, other]
Returns a tuple of these things:
def diff(other)
  raise ArgumentError, "Can only diff with a RubyVersion" unless other.is_a?(RubyVersion)
  if engine != other.engine && @input_engine
    [:engine, engine, other.engine]
  elsif versions.empty? || !matches?(versions, other.gem_version)
    [:version, versions_string(versions), versions_string(other.versions)]
  elsif @input_engine && !matches?(engine_versions, other.engine_gem_version)
    [:engine_version, versions_string(engine_versions), versions_string(other.engine_versions)]
  elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))
    [:patchlevel, patchlevel, other.patchlevel]
  end
end

def host

def host
  @host ||= [
    RbConfig::CONFIG["host_cpu"],
    RbConfig::CONFIG["host_vendor"],
    RbConfig::CONFIG["host_os"]
  ].join("-")
end

def initialize(versions, patchlevel, engine, engine_version)

def initialize(versions, patchlevel, engine, engine_version)
  # The parameters to this method must satisfy the
  # following constraints, which are verified in
  # the DSL:
  #
  # * If an engine is specified, an engine version
  #   must also be specified
  # * If an engine version is specified, an engine
  #   must also be specified
  # * If the engine is "ruby", the engine version
  #   must not be specified, or the engine version
  #   specified must match the version.
  @versions           = Array(versions)
  @gem_version        = Gem::Requirement.create(@versions.first).requirements.first.last
  @input_engine       = engine
  @engine             = engine || "ruby"
  @engine_versions    = (engine_version && Array(engine_version)) || @versions
  @engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last
  @patchlevel         = patchlevel
end

def matches?(requirements, version)

def matches?(requirements, version)
  Array(requirements).all? do |requirement|
    Gem::Requirement.create(requirement).satisfied_by?(Gem::Version.create(version))
  end
end

def single_version_string

def single_version_string
  to_s(gem_version)
end

def to_s(versions = self.versions)

def to_s(versions = self.versions)
  output = String.new("ruby #{versions_string(versions)}")
  output << "p#{patchlevel}" if patchlevel
  output << " (#{engine} #{versions_string(engine_versions)})" unless engine == "ruby"
  output
end

def versions_string(versions)

def versions_string(versions)
  Array(versions).join(", ")
end