Sha256: 29ac882d13b2e1e125cbf826419a5ef36aa66870ecce936a28c3d853ae584bff

Contents?: true

Size: 539 Bytes

Versions: 7

Compression:

Stored size: 539 Bytes

Contents

# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

module UnitMeasurements
  class UnitSystem
    include UnitMethods

    attr_reader :name, :primitive, :units

    def initialize(name)
      @name = name
      @primitive = nil
      @units = []
    end

    def add_unit(unit)
      @units << unit
    end

    def set_primitive(primitive)
      @primitive = unit_for!(primitive)
    end

    def primitive?(unit)
      @primitive.to_s == (unit.is_a?(Unit) ? unit.name : unit)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
unit_measurements-3.8.0 lib/unit_measurements/unit_system.rb
unit_measurements-3.7.0 lib/unit_measurements/unit_system.rb
unit_measurements-3.6.0 lib/unit_measurements/unit_system.rb
unit_measurements-3.5.0 lib/unit_measurements/unit_system.rb
unit_measurements-3.4.1 lib/unit_measurements/unit_system.rb
unit_measurements-3.3.0 lib/unit_measurements/unit_system.rb
unit_measurements-3.4.0 lib/unit_measurements/unit_system.rb