Class: Rich::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/rich/table.rb

Overview

Column definition for a Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header = "", footer: nil, header_style: nil, style: nil, footer_style: nil, justify: :left, min_width: nil, max_width: nil, no_wrap: false, overflow: :ellipsis, ratio: 1) ⇒ Column

Returns a new instance of Column.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rich/table.rb', line 45

def initialize(
  header = "",
  footer: nil,
  header_style: nil,
  style: nil,
  footer_style: nil,
  justify: :left,
  min_width: nil,
  max_width: nil,
  no_wrap: false,
  overflow: :ellipsis,
  ratio: 1
)
  @header = header.to_s
  @footer = footer
  @header_style = header_style.is_a?(String) ? Style.parse(header_style) : header_style
  @style = style.is_a?(String) ? Style.parse(style) : style
  @footer_style = footer_style.is_a?(String) ? Style.parse(footer_style) : footer_style
  @justify = justify
  @min_width = min_width
  @max_width = max_width
  @no_wrap = no_wrap
  @overflow = overflow
  @ratio = ratio
end

Instance Attribute Details

Returns Column footer.

Returns:

  • (String, nil)

    Column footer



16
17
18
# File 'lib/rich/table.rb', line 16

def footer
  @footer
end

Returns Footer style.

Returns:

  • (Style, nil)

    Footer style



25
26
27
# File 'lib/rich/table.rb', line 25

def footer_style
  @footer_style
end

#headerString (readonly)

Returns Column header.

Returns:

  • (String)

    Column header



13
14
15
# File 'lib/rich/table.rb', line 13

def header
  @header
end

#header_styleStyle? (readonly)

Returns Header style.

Returns:

  • (Style, nil)

    Header style



19
20
21
# File 'lib/rich/table.rb', line 19

def header_style
  @header_style
end

#justifySymbol (readonly)

Returns Justification (:left, :center, :right).

Returns:

  • (Symbol)

    Justification (:left, :center, :right)



28
29
30
# File 'lib/rich/table.rb', line 28

def justify
  @justify
end

#max_widthInteger? (readonly)

Returns Maximum width.

Returns:

  • (Integer, nil)

    Maximum width



34
35
36
# File 'lib/rich/table.rb', line 34

def max_width
  @max_width
end

#min_widthInteger? (readonly)

Returns Minimum width.

Returns:

  • (Integer, nil)

    Minimum width



31
32
33
# File 'lib/rich/table.rb', line 31

def min_width
  @min_width
end

#no_wrapBoolean (readonly)

Returns No wrap.

Returns:

  • (Boolean)

    No wrap



37
38
39
# File 'lib/rich/table.rb', line 37

def no_wrap
  @no_wrap
end

#overflowSymbol (readonly)

Returns Overflow handling (:fold, :crop, :ellipsis).

Returns:

  • (Symbol)

    Overflow handling (:fold, :crop, :ellipsis)



40
41
42
# File 'lib/rich/table.rb', line 40

def overflow
  @overflow
end

#ratioInteger (readonly)

Returns Ratio for flexible sizing.

Returns:

  • (Integer)

    Ratio for flexible sizing



43
44
45
# File 'lib/rich/table.rb', line 43

def ratio
  @ratio
end

#styleStyle? (readonly)

Returns Cell style.

Returns:

  • (Style, nil)

    Cell style



22
23
24
# File 'lib/rich/table.rb', line 22

def style
  @style
end