<commit_before>class Gosu::Color

  alias_method :gosu_initialize, :initialize

  #
  # Monkey-patching the initialize to allow for another Gosu::Color
  # and Strings.
  #
  def initialize(*args)
    if args.length == 1
      value = args.first
      if value.is_a? Gosu::Color
        gosu_initialize value.alpha, value.red, value.green, value.blue
      elsif value.is_a? String
        gosu_initialize *Array(self.class.from_string(value))
      end
    else
      gosu_initialize *args
    end
  end

  def self.from_string(value)
    parse_hex(value) || parse_rgb(value) || parse_rgba(value) || [ 255, 255, 255, 255 ]
  end

  def self.parse_rgba(rgba)
    if rgba =~ /rgba\(([\d]{1,3}),([\d]{1,3}),([\d]{1,3}),(\d(?:\.\d)?)\)/
      [ (255 * $4.to_f).floor.to_i, $1.to_i, $2.to_i, $3.to_i ]
    end
  end

  def self.parse_rgb(rgb)
    if rgb =~ /rgb\(([\d]{1,3}),([\d]{1,3}),([\d]{1,3})\)/
      [ 255, $1.to_i, $2.to_i, $3.to_i ]
    end
  end

  def self.parse_hex(hex)
    if hex =~ /#([A-Fa-f0-9]{6})/
      "0xFF#{$1}".to_i(16)
    end
  end

end<commit_msg>Renamed color method to #parse_string<commit_after>class Gosu::Color

  alias_method :gosu_initialize, :initialize

  #
  # Monkey-patching the initialize to allow for another Gosu::Color
  # and Strings.
  #
  def initialize(*args)
    if args.length == 1
      value = args.first
      if value.is_a? Gosu::Color
        gosu_initialize value.alpha, value.red, value.green, value.blue
      elsif value.is_a? String
        gosu_initialize *Array(self.class.parse_string(value))
      end
    else
      gosu_initialize *args
    end
  end

  def self.parse_string(value)
    parse_hex(value) || parse_rgb(value) || parse_rgba(value) || [ 255, 255, 255, 255 ]
  end

  def self.parse_rgba(rgba)
    if rgba =~ /rgba\(([\d]{1,3}),([\d]{1,3}),([\d]{1,3}),(\d(?:\.\d)?)\)/
      [ (255 * $4.to_f).floor.to_i, $1.to_i, $2.to_i, $3.to_i ]
    end
  end

  def self.parse_rgb(rgb)
    if rgb =~ /rgb\(([\d]{1,3}),([\d]{1,3}),([\d]{1,3})\)/
      [ 255, $1.to_i, $2.to_i, $3.to_i ]
    end
  end

  def self.parse_hex(hex)
    if hex =~ /#([A-Fa-f0-9]{6})/
      "0xFF#{$1}".to_i(16)
    end
  end

end
{'fraction_non_alphanumeric': 0.19049815498154982, 'fraction_numerical': 0.04151291512915129, 'mean_word_length': 2.6950596252129473, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3267641', 'n_tokens_mistral': 972, 'n_tokens_neox': 898, 'n_words': 169}