Sha256: 47c886bb9564194fe25cb7ff6833d6762821ca3b7fa5e482e0671ecbb2bc1514

Contents?: true

Size: 733 Bytes

Versions: 6

Compression:

Stored size: 733 Bytes

Contents

require "measured/version"
require "active_support/all"
require "bigdecimal"

module Measured
  class UnitError < StandardError ; end

  class << self
    def method_missing(method, *args)
      class_name = "Measured::#{ method }"

      if Measured::Measurable.subclasses.map(&:to_s).include?(class_name)
        klass = class_name.constantize

        Measured.define_singleton_method(method) do |value, unit|
          klass.new(value, unit)
        end

        klass.new(*args)
      else
        super
      end
    end
  end
end

require "measured/arithmetic"
require "measured/unit"
require "measured/conversion"
require "measured/conversion_table"
require "measured/measurable"
require "measured/case_sensitive_measurable"

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
measured-1.6.0 lib/measured/base.rb
measured-1.5.0 lib/measured/base.rb
measured-1.4.0 lib/measured/base.rb
measured-1.3.1 lib/measured/base.rb
measured-1.3.0 lib/measured/base.rb
measured-1.2.0 lib/measured/base.rb