module LeftRight

Direct including types

Defined in:

auto/left_right.cr

Instance Method Summary

Instance Method Detail

def canvas_lr : Array(Array(String)) #

Canvas is a variable that holds the cell of each string in grid format. In @canvas_ld, each element in the array is representing a row.

Example:

@canvas_lr = [["Rubys", "Crystals"], ["Emeralds", "Sapphires"], ["a", "b"]]

# It is Left-Right
# Rubys    Crystals 
# Emeralds Sapphires
# a        b  

[View source]
def canvas_lr=(canvas_lr : Array(Array(String))) #

Canvas is a variable that holds the cell of each string in grid format. In @canvas_ld, each element in the array is representing a row.

Example:

@canvas_lr = [["Rubys", "Crystals"], ["Emeralds", "Sapphires"], ["a", "b"]]

# It is Left-Right
# Rubys    Crystals 
# Emeralds Sapphires
# a        b  

[View source]
def col_width_lr : Array(Int32) #

Holds curently max width for every column.

Example:

@canvas_lr = [["Rubys", "Crystals"], ["Emeralds", "Sapphires"], ["a", "b"]]
@col_width_lr = [8, 9]

# => 1st column width is 6 char
# => 2nd column width is 7 char
# => 3rd column width is 9 char

[View source]
def col_width_lr=(col_width_lr : Array(Int32)) #

Holds curently max width for every column.

Example:

@canvas_lr = [["Rubys", "Crystals"], ["Emeralds", "Sapphires"], ["a", "b"]]
@col_width_lr = [8, 9]

# => 1st column width is 6 char
# => 2nd column width is 7 char
# => 3rd column width is 9 char

[View source]
def one_column_lr : Array(Array(String)) #

Return canvas with the size of one column. Its set @canvas_lr and calculate the @col_width_lr

Example:

@list = [
  "str_1",
  "str_30",
  "str_200",
  "str_4000",
  "str_50000",
]
one_column_lr # => [["str_1"], ["str_30"], ["str_200"], ["str_4000"], ["str_50000"]]

[View source]
def virtual_column_width_lr(row_size : Int32) : Array(Int32) #

Calculate each column width for canvas with virtually row item of row_size.

Returning the width of every column in type Array(Int32)

Example:

@list = [
  "str_1",
  "str_30",
  "str_200",
  "str_4000",
  "str_50000",
]
virtual_column_width_lr(3) # => [8, 9, 7]

# Virtual column would be like
# str_1    str_30    str_200
# str_4000 str_50000

virtual_column_width_lr(2) # => [9, 8]

# Virtual column would be like
# str_1     str_30
# str_200   str_4000
# str_50000

[View source]