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>
上の位の除去
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 |
# File 'lib/when_exe/coordinates.rb', line 1821 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>
上の位の付加
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 |
# File 'lib/when_exe/coordinates.rb', line 1804 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 |