Module: When::Coordinates::Temporal::OriginAndUpperDigits
- Defined in:
- lib/when_exe/coordinates.rb
Instance Method Summary collapse
-
#_decode_upper_structure(source) ⇒ Array<Numeric>
上の位の除去.
-
#_encode_upper_structure(source) ⇒ Array<Numeric>
上の位の付加.
Instance Method Details
#_decode_upper_structure(source) ⇒ Array<Numeric>
上の位の除去
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 |
# File 'lib/when_exe/coordinates.rb', line 2175 def _decode_upper_structure(source) date = source.dup u = 1 s = 0 @index_of_MSC.downto(1) do |i| s += u * (+date[i] - @indices[i-1].base) if (date[i]) u *= @indices[i-1].unit end date[@index_of_MSC] = s + u * (+date[0]) - @origin_of_MSC return date[@index_of_MSC..-1] end |
#_encode_upper_structure(source) ⇒ Array<Numeric>
上の位の付加
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 |
# File 'lib/when_exe/coordinates.rb', line 2158 def _encode_upper_structure(source) date = source.dup date[0] += @origin_of_MSC @index_of_MSC.downto(1) do |i| carry, date[0] = (+date[0]).divmod(@indices[i-1].unit) date[0] += @indices[i-1].base date.unshift(carry) end return date end |