Sha256: 7b6867bfa9a9beff18ca8c7564a1345f8805f523072070c2296ed39c9c463e98

Contents?: true

Size: 586 Bytes

Versions: 6

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

module Lite
  module Measurements
    module Helpers
      module ShiftHelper

        private

        def change_units(units, type:, from: nil, to: nil)
          if from
            units * type[from]
          else
            units / type[to]
          end
        end

        def equal_units?(from, to)
          from == to
        end

        def shift_units(units, type:, from: nil, to: nil)
          units = change_units(units, type: type, from: from)
          change_units(units, type: type, to: to)
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lite-measurements-2.0.0 lib/lite/measurements/helpers/shift_helper.rb
lite-measurements-1.1.1 lib/lite/measurements/helpers/shift_helper.rb
lite-measurements-1.1.0 lib/lite/measurements/helpers/shift_helper.rb
lite-measurements-1.0.2 lib/lite/measurements/helpers/shift_helper.rb
lite-measurements-1.0.1 lib/lite/measurements/helpers/shift_helper.rb
lite-measurements-1.0.0 lib/lite/measurements/helpers/shift_helper.rb