<commit_before># with_ruby_version

with_ruby_version is a DSL that helps you to implement Ruby version, patchlevel, engine and platform specific code

## Installation

Add this line to your application's Gemfile:

    gem 'with_ruby_version'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install with_ruby_version

## Usage

```ruby
require './lib/with_ruby_version'

class Example

  class << self
    def ping
      "pong"
    end
  end

  # ruby 1.8.7 # => "123"
  # ruby 2.0.0 # => "[1,2,3]"
  def array_to_string
    [1,2,3].to_s
  end

  # any ruby mri version that does not start with "1.8"
  with_ruby :version => /^((?!1\.[0-8]).*?)$/, :engine => 'ruby' do

    # also class methods can be defined
    class << self
      def ping
        "PONG"
      end
      # ...
    end

    # applied only if ruby 1.9.x or later
    def array_to_string
      [1,2,3].join
    end

  end

  # applied only if version and patchlevel matches
  with_ruby :version => 'X', :patchlevel => 'Y' do
    # ...
  end

  # applied only if engine and version matches
  with_ruby :engine => 'jruby', :version => 'x.x' do
    # ...
  end

  # applied only if platform matches
  with_ruby :platform => '...' do
    # ...
  end

  # alternative do specify ruby version specific implementation
  with_ruby_version 'X.Y.Z' do 
    # ...
  end

  with_ruby_patchlevel 'X.Y.Z' do 
    # ...
  end

  with_ruby_engine 'engine_xyz' do
    # ...
  end

  with_ruby_platform 'platform-i386' do
    # ...
  end

end

# 1.8.7
puts Example.ping # => 'pong'

# 1.8.7
puts Example.new.array_to_string # => "123"

# 2.0.0
puts Example.ping # => 'PONG'

# 2.0.0<commit_msg>README.md updated<commit_after># with_ruby_version

with_ruby_version is a DSL that helps you to implement Ruby version, patchlevel, engine and platform specific code

## Installation

Add this line to your application's Gemfile:

    gem 'with_ruby_version'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install with_ruby_version

## Usage

```ruby
require 'with_ruby_version'

class Example

  class << self
    def ping
      "pong"
    end
  end

  # ruby 1.8.7 # => "123"
  # ruby 2.0.0 # => "[1,2,3]"
  def array_to_string
    [1,2,3].to_s
  end

  # any mri version of ruby that is 1.9 or later
  with_ruby :version => /^((?!1\.[0-8]).*?)$/, :engine => 'ruby' do

    # also class methods can be defined
    class << self
      def ping
        "PONG"
      end
      # ...
    end

    # applied only if ruby 1.9.x or later
    def array_to_string
      [1,2,3].join
    end

  end

  # applied only if version and patchlevel matches
  with_ruby :version => 'x', :patchlevel => 'xyz' do
    # ...
  end

  # applied only if engine and version matches
  with_ruby :engine => 'jruby', :version => 'x.y.z' do
    # ...
  end

  # applied only if platform matches
  with_ruby :platform => '...' do
    # ...
  end

  # alternative do specify ruby version specific implementation
  with_ruby_version 'x.y.z' do 
    # ...
  end

  with_ruby_patchlevel 'zyx' do 
    # ...
  end

  with_ruby_engine 'engine_xyz' do
    # ...
  end

  with_ruby_platform 'platform-i386' do
    # ...
  end

end

# 1.8.7
puts Example.ping # => 'pong'

# 1.8.7
puts Example.new.array_to_string # => "123"

# 2.0.0
puts Example.ping # => 'PONG'

# 2.0.0
{'fraction_non_alphanumeric': 0.12473700030057108, 'fraction_numerical': 0.025849113315299068, 'mean_word_length': 2.3786802030456853, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '272585', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1173, 'n_words': 358}