<commit_before>require "height/parser"
require "height/parsers/base"
require "height/parsers/metric"
require "height/parsers/imperial"
require "height/formatters/base"
require "height/formatters/imperial"
require "height/formatters/metric"
require "height/units/base"
require "height/units/millimeters"
require "height/units/centimeters"
require "height/units/meters"
require "height/units/inches"
require "height/units/feet"
require "height/version"
require "height/core_extensions"

class Height
  include Comparable

  MILLIMETERS_IN_CENTIMETER = 10
  MILLIMETERS_IN_METER = 1000
  CENTIMETERS_IN_METER = 100
  MILLIMETERS_IN_INCH = 25.4
  INCHES_IN_FOOT = 12

  attr_reader :centimeters

  class << self
    attr_accessor :system_of_units
  end

  self.system_of_units = :metric

  def initialize(input)
    @centimeters = Parser.new(input).centimeters
  end

  def meters
    centimeters.to_meters
  end

  def inches
    centimeters.to_inches
  end

  def feet
    centimeters.to_feet
  end

  def <=>(other)
    centimeters <=> other.centimeters
  end

  def to_s(format = :default, system_of_units = nil)
    system_of_units ||= self.class.system_of_units

    case system_of_units
    when :metric
      Formatters::Metric.new(centimeters).format(format)
    when :imperial
      Formatters::Imperial.new(centimeters).format(format)
    else
      raise ::ArgumentError.new('Invalid system of units provided, use either :metric or :imperial')
    end
  end

end

<commit_msg>Use millimeters instead of centimeters in Height internals<commit_after>require "height/parser"
require "height/parsers/base"
require "height/parsers/metric"
require "height/parsers/imperial"
require "height/formatters/base"
require "height/formatters/imperial"
require "height/formatters/metric"
require "height/units/base"
require "height/units/millimeters"
require "height/units/centimeters"
require "height/units/meters"
require "height/units/inches"
require "height/units/feet"
require "height/version"
require "height/core_extensions"

class Height
  include Comparable

  MILLIMETERS_IN_CENTIMETER = 10
  MILLIMETERS_IN_METER = 1000
  CENTIMETERS_IN_METER = 100
  MILLIMETERS_IN_INCH = 25.4
  INCHES_IN_FOOT = 12

  class << self
    attr_accessor :system_of_units
  end

  self.system_of_units = :metric

  def initialize(input)
    @millimeters = Parser.new(input).millimeters
  end

  def millimeters
    @millimeters
  end

  def centimeters
    millimeters.to_centimeters
  end

  def meters
    millimeters.to_meters
  end

  def inches
    millimeters.to_inches
  end

  def feet
    millimeters.to_feet
  end

  def <=>(other)
    millimeters <=> other.millimeters
  end

  def to_s(format = :default, system_of_units = nil)
    system_of_units ||= self.class.system_of_units

    case system_of_units
    when :metric
      Formatters::Metric.new(millimeters).format(format)
    when :imperial
      Formatters::Imperial.new(millimeters).format(format)
    else
      raise ::ArgumentError.new('Invalid system of units provided, use either :metric or :imperial')
    end
  end

end


{'fraction_non_alphanumeric': 0.0859552384041518, 'fraction_numerical': 0.009082062925721699, 'mean_word_length': 4.174496644295302, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '2073855', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1013, 'n_words': 223}