Class: Astronoby::Configuration
- Inherits:
-
Object
- Object
- Astronoby::Configuration
- Defined in:
- lib/astronoby/configuration.rb
Constant Summary collapse
- DEFAULT_PRECISIONS =
{ geometric: 9, # 8.64e-5 seconds nutation: 2, # 864 seconds precession: 2, # 864 seconds rise_transit_set: 5 # 0.1 seconds }.freeze
Instance Attribute Summary collapse
-
#cache_enabled ⇒ Object
Returns the value of attribute cache_enabled.
-
#cache_precisions ⇒ Object
Returns the value of attribute cache_precisions.
Instance Method Summary collapse
-
#cache ⇒ Astronoby::Cache, Astronoby::NullCache
Get the cache instance (singleton or null cache).
- #cache_enabled? ⇒ Boolean
-
#cache_precision(type, precision = nil) ⇒ Numeric
Configure cache precision for specific calculation types.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#reset_cache! ⇒ void
Reset cache instance (useful for testing or configuration changes).
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 19 |
# File 'lib/astronoby/configuration.rb', line 15 def initialize @cache_enabled = false @cache_precisions = DEFAULT_PRECISIONS.dup @cache_instance = nil end |
Instance Attribute Details
#cache_enabled ⇒ Object
Returns the value of attribute cache_enabled.
12 13 14 |
# File 'lib/astronoby/configuration.rb', line 12 def cache_enabled @cache_enabled end |
#cache_precisions ⇒ Object
Returns the value of attribute cache_precisions.
13 14 15 |
# File 'lib/astronoby/configuration.rb', line 13 def cache_precisions @cache_precisions end |
Instance Method Details
#cache ⇒ Astronoby::Cache, Astronoby::NullCache
Get the cache instance (singleton or null cache)
43 44 45 46 47 48 49 |
# File 'lib/astronoby/configuration.rb', line 43 def cache if cache_enabled? Cache.instance else NullCache.instance end end |
#cache_enabled? ⇒ Boolean
51 52 53 |
# File 'lib/astronoby/configuration.rb', line 51 def cache_enabled? @cache_enabled end |
#cache_precision(type, precision = nil) ⇒ Numeric
Configure cache precision for specific calculation types
25 26 27 28 29 30 31 |
# File 'lib/astronoby/configuration.rb', line 25 def cache_precision(type, precision = nil) if precision.nil? @cache_precisions[type] || DEFAULT_PRECISIONS[:geometric] else @cache_precisions[type] = precision end end |
#reset_cache! ⇒ void
This method returns an undefined value.
Reset cache instance (useful for testing or configuration changes)
57 58 59 |
# File 'lib/astronoby/configuration.rb', line 57 def reset_cache! cache.clear end |