Class: Synvert::Core::Rewriter::RubyVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/synvert/core/rewriter/ruby_version.rb

Overview

GemSpec checks and compares gem version.

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ RubyVersion

Initialize a ruby_version.

Parameters:

  • version (String)

    ruby version


9
10
11
# File 'lib/synvert/core/rewriter/ruby_version.rb', line 9

def initialize(version)
  @version = version
end

Instance Method Details

#match?Boolean

Check if the specified ruby version matches current ruby version.

Returns:

  • (Boolean)

    true if matches, otherwise false.


16
17
18
19
20
# File 'lib/synvert/core/rewriter/ruby_version.rb', line 16

def match?
  # Gem::Version initialize will strip RUBY_VERSION directly in ruby 1.9,
  # which is solved from ruby 2.0.0, which calls dup internally.
  Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new(@version)
end