Sha256: 598a09802fe6051553ccaabaf465cd8838039a22835ac4fbda9a7065980a82b6

Contents?: true

Size: 652 Bytes

Versions: 4

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module Rordash
  module NumericUtil
    class << self
      module Unit
        FEET = :ft
        METER = :m
      end

      def numeric?(value)
        !Float(value.to_s).nil?
      rescue StandardError
        false
      end

      def convert_unit(value, from_unit:, to_unit:)
        Measured::Length.new(value, from_unit).convert_to(to_unit).value.to_f
      end

      def convert_unit_sq(value, from_unit:, to_unit:)
        value = value.is_a?(String) ? BigDecimal(value) : value
        val = convert_unit(value, from_unit: from_unit, to_unit: to_unit)
        (val * val) / value
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rordash-0.1.3 lib/rordash/numeric_util.rb
rordash-0.1.2 lib/rordash/numeric_util.rb
rordash-0.1.1 lib/rordash/numeric_util.rb
rordash-0.1.0 lib/rordash/numeric_util.rb