<commit_before>module Spree
  class LocalizedNumber

    # Strips all non-price-like characters from the number, taking into account locale settings.
    def self.parse(number)
      return number unless number.is_a?(String)

      separator, delimiter = I18n.t([:'number.currency.format.separator', :'number.currency.format.delimiter'])
      non_number_characters = /[^0-9\-#{separator}]/

      # strip everything else first
      number.gsub!(non_number_characters, '')
      # then replace the locale-specific decimal separator with the standard separator if necessary
      number.gsub!(separator, '.') unless separator == '.'

      number.to_d
    end

  end
end<commit_msg>Document Spree::LocalizedNumber<commit_after>module Spree
  class LocalizedNumber
    # Given a string, strips all non-price-like characters from it,
    # taking into account locale settings. Returns the input given anything
    # else.
    #
    # @param number [String, anything] the number to be parsed or anything else
    # @return [BigDecimal, anything] the number parsed from the string passed
    #   in, or whatever you passed in
    def self.parse(number)
      return number unless number.is_a?(String)

      separator, delimiter = I18n.t([:'number.currency.format.separator', :'number.currency.format.delimiter'])
      non_number_characters = /[^0-9\-#{separator}]/

      # strip everything else first
      number.gsub!(non_number_characters, '')
      # then replace the locale-specific decimal separator with the standard separator if necessary
      number.gsub!(separator, '.') unless separator == '.'

      number.to_d
    end
  end
end
{'fraction_non_alphanumeric': 0.09811090798293723, 'fraction_numerical': 0.004875076173065204, 'mean_word_length': 3.4021447721179623, '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': '4872264', 'n_tokens_mistral': 467, 'n_tokens_neox': 444, 'n_words': 140}