<commit_before>class Raindrops
  def self.convert(number)
    Raindrops.new(number).to_s
  end

  def initialize(number)
    @number = number
  end

  def to_s
    special? ? special_string : ordinary_string
  end

  private

  attr_reader :number

  def special?
    multiple_at_least_one? 3, 5, 7
  end

  def special_string
    pling + plang + plong
  end

  def ordinary_string
    number.to_s
  end

  def multiple_at_least_one?(*divisors)
    divisors.any? { |divisor| multiple? divisor }
  end

  def pling
    multiple?(3) ? 'Pling' : ''
  end

  def plang
    multiple?(5) ? 'Plang' : ''
  end

  def plong
    multiple?(7) ? 'Plong' : ''
  end

  def multiple?(divisor)
    (number % divisor).zero?
  end
end<commit_msg>:construction_worker: Ruby Raindrops - Generalised implementation using 'special cases' hash.<commit_after>class Raindrops
  def self.convert(number)
    Raindrops.new(number).to_s
  end

  def initialize(number)
    @number = number
  end

  def to_s
    special? ? special_string : ordinary_string
  end

  private

  attr_reader :number

  def special?
    multiple_at_least_one? special_cases.keys
  end

  def special_string
    special_cases.keys.reduce('') do |text, divisor|
      text + (multiple?(divisor) ? special_cases[divisor] : '')
    end
  end

  def ordinary_string
    number.to_s
  end

  def multiple_at_least_one?(*divisors)
    divisors.flatten.any? { |divisor| multiple? divisor }
  end

  def multiple?(divisor)
    (number % divisor).zero?
  end

  def special_cases
    {
      3 => 'Pling',
      5 => 'Plang',
      7 => 'Plong'
    }
  end
end
{'fraction_non_alphanumeric': 0.09731752963194011, 'fraction_numerical': 0.0056144728633811605, 'mean_word_length': 2.941031941031941, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '331100', 'n_tokens_mistral': 591, 'n_tokens_neox': 557, 'n_words': 134}