Module: When::Coordinates::Temporal::IndexConversion
- Defined in:
- lib/when_exe/coordinates.rb
Instance Method Summary collapse
-
#_from_index(date) ⇒ When::Coordinates::Pair
indexのPair化.
-
#_to_index(date) ⇒ When::Coordinates::Pair
Pairのindex化.
Instance Method Details
#_from_index(date) ⇒ When::Coordinates::Pair
indexのPair化
2027 2028 2029 2030 2031 2032 2033 2034 2035 |
# File 'lib/when_exe/coordinates.rb', line 2027 def _from_index(date) return nil unless @pair[date.size-1] ids = _ids(date[0..-2]) m = ids[date[-1]] if (ids) return Pair._force_pair(m) if (ids && m) return Pair.new(+date[-1]+@base[date.length-1], 0) rescue ArgumentError nil end |
#_to_index(date) ⇒ When::Coordinates::Pair
Pairのindex化
2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 |
# File 'lib/when_exe/coordinates.rb', line 2044 def _to_index(date) return nil unless @pair[date.size-1] ids = _ids(date[0..-2]) i = ids.index(date[-1]) if ids return i if i return nil unless ids && date[-1].kind_of?(Pair) digit = Pair.new(date[-1].trunk, date[-1].branch) while digit.branch > 0 digit.branch -= 1 i = ids.index(digit) return i + date[-1].branch - digit.branch if i end return nil rescue ArgumentError nil end |