lib/tzinfo/offset_rationals.rb in tzinfo-1.0.1 vs lib/tzinfo/offset_rationals.rb in tzinfo-1.1.0

- old
+ new

@@ -1,7 +1,7 @@ #-- -# Copyright (c) 2006-2010 Philip Ross +# Copyright (c) 2006-2013 Philip Ross # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -24,11 +24,13 @@ module TZInfo # Provides a method for getting Rationals for a timezone offset in seconds. # Pre-reduced rationals are returned for all the half-hour intervals between - # -14 and +14 hours to avoid having to call gcd at runtime. + # -14 and +14 hours to avoid having to call gcd at runtime. + # + # @private module OffsetRationals #:nodoc: @@rational_cache = { -50400 => RubyCoreSupport.rational_new!(-7,12), -48600 => RubyCoreSupport.rational_new!(-9,16), -46800 => RubyCoreSupport.rational_new!(-13,24), @@ -83,10 +85,10 @@ 41400 => RubyCoreSupport.rational_new!(23,48), 43200 => RubyCoreSupport.rational_new!(1,2), 45000 => RubyCoreSupport.rational_new!(25,48), 46800 => RubyCoreSupport.rational_new!(13,24), 48600 => RubyCoreSupport.rational_new!(9,16), - 50400 => RubyCoreSupport.rational_new!(7,12)} + 50400 => RubyCoreSupport.rational_new!(7,12)}.freeze # Returns a Rational expressing the fraction of a day that offset in # seconds represents (i.e. equivalent to Rational(offset, 86400)). def rational_for_offset(offset) @@rational_cache[offset] || Rational(offset, 86400)