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>
上の位の除去
2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 |
# File 'lib/when_exe/coordinates.rb', line 2162 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>
上の位の付加
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 |
# File 'lib/when_exe/coordinates.rb', line 2145 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 |