Module: When::Coordinates::Temporal::OriginAndUpperDigits

Defined in:
lib/when_exe/coordinates.rb

Instance Method Summary collapse

Instance Method Details

#_decode_upper_structure(source) ⇒ Array<Numeric>

上の位の除去


2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
# File 'lib/when_exe/coordinates.rb', line 2032

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>

上の位の付加


2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
# File 'lib/when_exe/coordinates.rb', line 2015

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