Class: Astronoby::CacheKey
- Inherits:
-
Object
- Object
- Astronoby::CacheKey
- Defined in:
- lib/astronoby/cache.rb
Class Method Summary collapse
-
.generate(type, instant, *components) ⇒ Array
Generate a cache key with appropriate precision.
-
.round_terrestrial_time(tt, precision) ⇒ Numeric
Round terrestrial time to specified precision.
Class Method Details
.generate(type, instant, *components) ⇒ Array
Generate a cache key with appropriate precision
170 171 172 173 174 175 176 |
# File 'lib/astronoby/cache.rb', line 170 def generate(type, instant, *components) return nil unless Astronoby.configuration.cache_enabled? precision = Astronoby.configuration.cache_precision(type) rounded_tt = round_terrestrial_time(instant.tt, precision) [type, rounded_tt, *components] end |
.round_terrestrial_time(tt, precision) ⇒ Numeric
Round terrestrial time to specified precision
182 183 184 185 186 |
# File 'lib/astronoby/cache.rb', line 182 def round_terrestrial_time(tt, precision) return tt if precision <= 0 tt.round(precision) end |