<commit_before># encoding: UTF-8
class Money
  module Formatting
    def self.included(base)
      [
        [:thousands_separator, :delimiter, ","],
        [:decimal_mark, :separator, "."]
      ].each do |method, name, character|
        define_i18n_method(base, method, name, character)
      end
    end

    def self.define_i18n_method(base, method, name, character)
      base.class_eval do
        define_method(method) do
          if self.class.use_i18n
            begin
              I18n.t name, :scope => "number.currency.format", :raise => true
            rescue I18n::MissingTranslationData
              I18n.t name, :scope =>"number.format", :default => (currency.send(method) || character)
            end
          else
            currency.send(method) || character
          end
        end
        alias_method name, method
      end
    end

    # Creates a formatted price string according to several rules.
    #
    # @param [Hash] rules The options used to format the string.
    #
    # @return [String]
    #
    # @option *rules [Boolean, String] :display_free (false) Whether a zero
    #  amount of money should be formatted of "free" or as the supplied string.
    #
    # @example
    #   Money.us_dollar(0).format(:display_free => true)     #=> "free"
    #   Money.us_dollar(0).format(:display_free => "gratis") #=> "gratis"
    #   Money.us_dollar(0).format                            #=> "$0.00"
    #
    # @option *rules [Boolean] :with_currency (false) Whether the currency name
    #  should be appended to the result string.
    #
    # @example
    #   Money.ca_dollar(100).format #=> "$1.00"
    #   Money.ca_dollar(100).format(:with_currency => true) #=> "$1.00 CAD"
    #   Money.us_dollar(85).format(:with_currency => true)  #=> "$0.85 USD"
    #
    # @option *rules [Boolean] :rounded_infinite_precision (false) Whether the
    #  amount of money should be rounded when using infinite_precision
    #
    # @example
    #   Money.us_dollar(100.1).format #=> "$1.001"<commit_msg>Revert "Ensure formatting methods are defined as public with class_eval"<commit_after># encoding: UTF-8
class Money
  module Formatting
    def self.included(base)
      [
        [:thousands_separator, :delimiter, ","],
        [:decimal_mark, :separator, "."]
      ].each do |method, name, character|
        define_i18n_method(method, name, character)
      end
    end

    def self.define_i18n_method(method, name, character)
      define_method(method) do
        if self.class.use_i18n
          begin
            I18n.t name, :scope => "number.currency.format", :raise => true
          rescue I18n::MissingTranslationData
            I18n.t name, :scope =>"number.format", :default => (currency.send(method) || character)
          end
        else
          currency.send(method) || character
        end
      end
      alias_method name, method
    end

    # Creates a formatted price string according to several rules.
    #
    # @param [Hash] rules The options used to format the string.
    #
    # @return [String]
    #
    # @option *rules [Boolean, String] :display_free (false) Whether a zero
    #  amount of money should be formatted of "free" or as the supplied string.
    #
    # @example
    #   Money.us_dollar(0).format(:display_free => true)     #=> "free"
    #   Money.us_dollar(0).format(:display_free => "gratis") #=> "gratis"
    #   Money.us_dollar(0).format                            #=> "$0.00"
    #
    # @option *rules [Boolean] :with_currency (false) Whether the currency name
    #  should be appended to the result string.
    #
    # @example
    #   Money.ca_dollar(100).format #=> "$1.00"
    #   Money.ca_dollar(100).format(:with_currency => true) #=> "$1.00 CAD"
    #   Money.us_dollar(85).format(:with_currency => true)  #=> "$0.85 USD"
    #
    # @option *rules [Boolean] :rounded_infinite_precision (false) Whether the
    #  amount of money should be rounded when using infinite_precision
    #
    # @example
    #   Money.us_dollar(100.1).format #=> "$1.001"
{'fraction_non_alphanumeric': 0.12376482213438735, 'fraction_numerical': 0.021739130434782608, 'mean_word_length': 2.437181663837012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '7032471', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1230, 'n_words': 323}