<commit_before>module Amazon
  class Image
    attr_reader :url, :width, :height
    
    def initialize(url, width, height)
      @url = url
      width = Measurement.new(width, 'pixels') unless width.is_a? Measurement
      @width = width
      height = Measurement.new(height, 'pixels') unless height.is_a? Measurement
      @height = height
    end
    
    def ==(other)
      return nil unless other.is_a? Image
      @url == other.url and @width == other.width and @height == other.height
    end
    
    def size
      unless height.units == 'pixels' and width.units == 'pixels'
        raise 'size not available for images not denominated in pixels'
      end
      
      "#{width.value.round}x#{height.value.round}"
    end
    
    def inspect
      sprintf("#<%s: %s,%sx%s>", self.class.to_s, self.url, self.width, self.height)
    end    
  end
end
<commit_msg>Extract Image#to_measurement helper<commit_after>module Amazon
  class Image
    attr_reader :url, :width, :height

    def initialize(url, width, height)
      @url = url
      @width = to_measurement(width)
      @height = to_measurement(height)
    end

    def ==(other)
      return nil unless other.is_a? Image
      @url == other.url and @width == other.width and @height == other.height
    end

    def size
      unless height.units == 'pixels' and width.units == 'pixels'
        raise 'size not available for images not denominated in pixels'
      end

      "#{width.value.round}x#{height.value.round}"
    end

    def inspect
      sprintf("#<%s: %s,%sx%s>", self.class.to_s, self.url, self.width, self.height)
    end

  private
    def to_measurement(arg)
      arg.is_a?(Measurement) ? arg : Measurement.new(arg, 'pixels')
    end
  end
end

{'fraction_non_alphanumeric': 0.11578341013824885, 'fraction_numerical': 0.0, 'mean_word_length': 2.603734439834025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '335358', 'n_tokens_mistral': 563, 'n_tokens_neox': 550, 'n_words': 156}