Class: RubyRich::Columns::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_rich/columns.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width: nil, align: :left, padding: 1, title: nil) ⇒ Column

Returns a new instance of Column.



6
7
8
9
10
11
12
# File 'lib/ruby_rich/columns.rb', line 6

def initialize(width: nil, align: :left, padding: 1, title: nil)
  @content = []
  @width = width
  @align = align
  @padding = padding
  @title = title
end

Instance Attribute Details

#alignObject

Returns the value of attribute align.



4
5
6
# File 'lib/ruby_rich/columns.rb', line 4

def align
  @align
end

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/ruby_rich/columns.rb', line 4

def content
  @content
end

#paddingObject

Returns the value of attribute padding.



4
5
6
# File 'lib/ruby_rich/columns.rb', line 4

def padding
  @padding
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/ruby_rich/columns.rb', line 4

def title
  @title
end

#widthObject

Returns the value of attribute width.



4
5
6
# File 'lib/ruby_rich/columns.rb', line 4

def width
  @width
end

Instance Method Details

#<<(text) ⇒ Object



19
20
21
# File 'lib/ruby_rich/columns.rb', line 19

def <<(text)
  add(text)
end

#add(text) ⇒ Object



14
15
16
17
# File 'lib/ruby_rich/columns.rb', line 14

def add(text)
  @content << text.to_s
  self
end

#clearObject



23
24
25
26
# File 'lib/ruby_rich/columns.rb', line 23

def clear
  @content.clear
  self
end

#heightObject



32
33
34
# File 'lib/ruby_rich/columns.rb', line 32

def height
  @content.length
end

#linesObject



28
29
30
# File 'lib/ruby_rich/columns.rb', line 28

def lines
  @content
end