<commit_before>module Mws::Apis::Feeds

  class Measurement

    attr_reader :amount, :unit

    def initialize(amount, unit)
      @amount = amount
      @units = self.class.const_get(:Unit)
      raise ArgumentError, "Invalid unit of measure '#{unit}'" if @units.for(unit).nil?
      @unit = unit
    end

    def ==(other)
      return true if equal? other
      return false unless other.class == self.class
      @amount == other.amount and @unit == other.unit
    end

    def to_xml(name=nil, parent=nil)
      name ||= self.class.name.split('::').last
      Mws::Serializer.leaf name, parent, @amount, unitOfMeasure: @units.for(@unit).val
    end

  end

end

<commit_msg>Restrict the number of decimal places to 2 if present<commit_after>module Mws::Apis::Feeds

  class Measurement

    attr_reader :amount, :unit

    def initialize(amount, unit)
      @amount = amount
      @units = self.class.const_get(:Unit)
      raise ArgumentError, "Invalid unit of measure '#{unit}'" if @units.for(unit).nil?
      @unit = unit
    end

    def ==(other)
      return true if equal? other
      return false unless other.class == self.class
      @amount == other.amount and @unit == other.unit
    end

    def to_xml(name=nil, parent=nil)
      name ||= self.class.name.split('::').last
      amount = @amount 
      amount = '%.2f' % amount if amount.to_s =~ /\d*\.\d\d+/
      Mws::Serializer.leaf name, parent, amount, unitOfMeasure: @units.for(@unit).val
    end

  end

end


{'fraction_non_alphanumeric': 0.12996632996632998, 'fraction_numerical': 0.0013468013468013469, 'mean_word_length': 2.7908163265306123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1764586', 'n_tokens_mistral': 483, 'n_tokens_neox': 461, 'n_words': 133}