Sha256: 0ad27a35f7f76ffde1caf3916761d2ef7d0eb7841646836ed503ea2b3d844b36
Contents?: true
Size: 644 Bytes
Versions: 5
Compression:
Stored size: 644 Bytes
Contents
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
5 entries across 5 versions & 1 rubygems