Sha256: fdbb63ab65bd36c8414cb73776f56f2c36bb917f39b9eabd7a4c0a372d7bb127
Contents?: true
Size: 675 Bytes
Versions: 1
Compression:
Stored size: 675 Bytes
Contents
# frozen_string_literal: true module RubyUnits # Performance optimizations to avoid creating units unnecessarily class Cache attr_accessor :data def initialize clear end # @param key [String, #to_unit] # @return [RubyUnits::Unit, nil] def get(key) key = key&.to_unit&.units unless key.is_a?(String) data[key] end # @param key [String, #to_unit] # @return [void] def set(key, value) key = key.to_unit.units unless key.is_a?(String) data[key] = value end # @return [Array<String>] def keys data.keys end # Reset the cache def clear @data = {} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-units-4.1.0 | lib/ruby_units/cache.rb |