<commit_before>require 'simplecheck/version'
require 'simplecheck/check_failed'

module Simplecheck
  def check( *arguments, &block )
    check_passed, message = if block_given?
                              check_arguments( *(arguments + [ block ]) )
                            else
                              check_arguments( *arguments )
                            end

    check_arguments( *arguments )

    if check_passed
      arguments
    else
      handle_failure( message )
    end
  end

  private
  def check_arguments( *arguments )
    case arguments.size
    when 1
      check_bool( arguments[ 0 ] )
    else
      check_threequal( *arguments )
    end
  end

  def check_bool( condition )
    if condition 
      [ true, nil ] 
    else
      [ false, 'Condition is not true' ]
    end
  end

  def check_threequal( *arguments, receiver )
    if invalid_argument = arguments.find{ |argument| !( receiver === argument )}
      [ false, "#{ invalid_argument } does not satisfy #{ receiver }" ]
    else
      [ true, nil ] <commit_msg>Refactor<commit_after>require 'simplecheck/version'
require 'simplecheck/check_failed'

module Simplecheck
  def check( *arguments, &block )
    check_passed, message = if block_given?
                              check_arguments_with_block( arguments, block )
                            else
                              check_arguments( arguments )
                            end

    if check_passed
      arguments
    else
      handle_failure( message )
    end
  end

  private
  def check_arguments( arguments )
    case arguments.size
    when 1
      check_bool( arguments[ 0 ])
    else
      check_threequal( *arguments )
    end
  end

  def check_arguments_with_block( arguments, block )
    check_arguments(( arguments + [ block ]))
  end

  def check_bool( condition )
    if condition 
      [ true, nil ] 
    else
      [ false, 'Condition is not true' ]
    end
  end

  def check_threequal( *arguments, receiver )
    if invalid_argument = arguments.find{ |argument| !( receiver === argument )}
      [ false, "#{ invalid_argument } does not satisfy #{ receiver }" ]
    else
      [ true, nil ] 
{'fraction_non_alphanumeric': 0.07720588235294118, 'fraction_numerical': 0.001838235294117647, 'mean_word_length': 1.9821917808219178, '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': '3697161', 'n_tokens_mistral': 602, 'n_tokens_neox': 579, 'n_words': 168}