<commit_before>if RUBY_VERSION =~ /^1\.8/
  require 'base64'
end

class String
  def as_base64
    Rapuncel::Base64String.new self
  end
end

module Rapuncel
  class Base64String < String
    def base64_encoded
      if RUBY_VERSION =~ /^1\.9/
        [self].pack 'm'
      else
        Base64.encode64 self
      end
    end
    
    class << self
      def decode_base64 string
        if RUBY_VERSION =~ /^1\.9/
          new string.unpack('m')[0]
        else
          new Base64.decode64 string
        end
      end
    end
  end
end<commit_msg>check ruby version not on each encode/decode, but only once at startup<commit_after>if RUBY_VERSION =~ /^1\.8/
  require 'base64'
end

class String
  def as_base64
    Rapuncel::Base64String.new self
  end
end

module Rapuncel
  class Base64String < String

    if RUBY_VERSION =~ /^1\.9/

      def base64_encoded
        [self].pack 'm'
      end
    
      def self.decode_base64 string
        new string.unpack('m')[0]
      end
      
    else

      def base64_encoded
        Base64.encode64 self
      end
    
      def self.decode_base64 string
        new Base64.decode64 string
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.07429547395388557, 'fraction_numerical': 0.04782237403928266, 'mean_word_length': 1.8866995073891626, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '2337834', 'n_tokens_mistral': 430, 'n_tokens_neox': 394, 'n_words': 109}