Method: UnitMeasurements::Cache#initialize

Defined in:
lib/unit_measurements/cache.rb

#initialize(unit_group) ⇒ Cache

Initializes a new Cache instance for a specific unit group.

Initialization first ensures existence of the cache directory. If the cache directory does not exist, it gets created.

Author:

Since:

  • 5.2.0



39
40
41
42
43
# File 'lib/unit_measurements/cache.rb', line 39

def initialize(unit_group)
  ensure_cache_directory_exists
  @cache_file = build_cache_file_path(unit_group)
  @cached_data ||= load_cache
end