Module: Sashite::Cell::Formatter Private

Defined in:
lib/sashite/cell/formatter.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Formats index arrays into CELL coordinate strings.

This module handles the conversion from numeric indices to their CELL string representation following the cyclic pattern:

  • Dimension 1, 4, 7…: lowercase letters (a-z, aa-iv)

  • Dimension 2, 5, 8…: positive integers (1-256)

  • Dimension 3, 6, 9…: uppercase letters (A-Z, AA-IV)

Examples:

Formatter.indices_to_string([4, 3])    # => "e4"
Formatter.indices_to_string([0, 0, 0]) # => "a1A"

Class Method Summary collapse

Class Method Details

.indices_to_string(indices) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Formats an indices array to a CELL string.

Examples:

Formatter.indices_to_string([4, 3])       # => "e4"
Formatter.indices_to_string([255, 255, 255]) # => "iv256IV"

Parameters:

  • indices (Array<Integer>)

    0-indexed coordinate values

Returns:

  • (String)

    CELL coordinate string



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sashite/cell/formatter.rb', line 27

def self.indices_to_string(indices)
  result = +""

  indices.each_with_index do |index, i|
    dimension_type = i % 3

    result << case dimension_type
              when 0 then encode_to_lower(index)
              when 1 then encode_to_number(index)
              when 2 then encode_to_upper(index)
              end
  end

  result.freeze
end