Class: Bundler::RubyVersion
- Inherits:
-
Object
- Object
- Bundler::RubyVersion
- Defined in:
- lib/bundler/ruby_version.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#engine ⇒ Object
readonly
Returns the value of attribute engine.
-
#engine_version ⇒ Object
readonly
Returns the value of attribute engine_version.
-
#patchlevel ⇒ Object
readonly
Returns the value of attribute patchlevel.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#diff(other) ⇒ Object
Returns a tuple of these things: [diff, this, other] The priority of attributes are 1.
- #host ⇒ Object
-
#initialize(version, patchlevel, engine, engine_version) ⇒ RubyVersion
constructor
A new instance of RubyVersion.
- #to_s ⇒ Object
Constructor Details
#initialize(version, patchlevel, engine, engine_version) ⇒ RubyVersion
Returns a new instance of RubyVersion.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bundler/ruby_version.rb', line 5 def initialize(version, 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. @version = version @engine = engine || "ruby" # keep track of the engine specified by the user @input_engine = engine @engine_version = engine_version || version @patchlevel = patchlevel end |
Instance Attribute Details
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
3 4 5 |
# File 'lib/bundler/ruby_version.rb', line 3 def engine @engine end |
#engine_version ⇒ Object (readonly)
Returns the value of attribute engine_version.
3 4 5 |
# File 'lib/bundler/ruby_version.rb', line 3 def engine_version @engine_version end |
#patchlevel ⇒ Object (readonly)
Returns the value of attribute patchlevel.
3 4 5 |
# File 'lib/bundler/ruby_version.rb', line 3 def patchlevel @patchlevel end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/bundler/ruby_version.rb', line 3 def version @version end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/bundler/ruby_version.rb', line 34 def ==(other) version == other.version && engine == other.engine && engine_version == other.engine_version && patchlevel == other.patchlevel end |
#diff(other) ⇒ Object
Returns a tuple of these things:
[diff, this, other]
The priority of attributes are
1. engine
2. ruby_version
3. engine_version
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bundler/ruby_version.rb', line 47 def diff(other) if engine != other.engine && @input_engine [ :engine, engine, other.engine ] elsif version != other.version [ :version, version, other.version ] elsif engine_version != other.engine_version && @input_engine [ :engine_version, engine_version, other.engine_version ] elsif patchlevel != other.patchlevel && @patchlevel [ :patchlevel, patchlevel, other.patchlevel ] else nil end end |
#host ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/bundler/ruby_version.rb', line 61 def host @host ||= [ RbConfig::CONFIG["host_cpu"], RbConfig::CONFIG["host_vendor"], RbConfig::CONFIG["host_os"] ].join("-") end |
#to_s ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/bundler/ruby_version.rb', line 26 def to_s output = "ruby #{version}" output << "p#{patchlevel}" if patchlevel output << " (#{engine} #{engine_version})" unless engine == "ruby" output end |