Sha256: 8e91b0d3330db51ff366f4709b299116a43d70a10517359dbd89cd7510f9d7cb

Contents?: true

Size: 384 Bytes

Versions: 7

Compression:

Stored size: 384 Bytes

Contents

module RubyUnits
  class Unit < Numeric
    @@cached_units = {}

    class Cache
      def self.get(key = nil)
        key.nil? ? @@cached_units : @@cached_units[key]
      end

      def self.set(key, value)
        @@cached_units[key] = value
      end

      def self.clear
        @@cached_units = {}
        @@base_unit_cache = {}
        Unit.new(1)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby-units-2.4.1 lib/ruby_units/cache.rb
ruby-units-2.3.2 lib/ruby_units/cache.rb
ruby-units-2.3.1 lib/ruby_units/cache.rb
ruby-units-2.3.0 lib/ruby_units/cache.rb
ruby-units-2.2.1 lib/ruby_units/cache.rb
ruby-units-2.2.0 lib/ruby_units/cache.rb
ruby-units-2.1.0 lib/ruby_units/cache.rb