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>
上の位の除去
1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 |
# File 'lib/when_exe/coordinates.rb', line 1825 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>
上の位の付加
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 |
# File 'lib/when_exe/coordinates.rb', line 1808 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 |