Class: NattyUI::TableRenderer::Cell
- Inherits:
-
Object
- Object
- NattyUI::TableRenderer::Cell
- Defined in:
- lib/natty-ui/table_renderer.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #correct_height(height) ⇒ Object
-
#initialize(cell, width) ⇒ Cell
constructor
A new instance of Cell.
Constructor Details
#initialize(cell, width) ⇒ Cell
Returns a new instance of Cell.
97 98 99 100 101 102 103 104 105 |
# File 'lib/natty-ui/table_renderer.rb', line 97 def initialize(cell, width) return @text = [] unless cell att = cell.attributes @padding = att.padding.dup @align = att.align @vertical = att.vertical @style = att.style_bbcode @text = width_corrected(cell.text, width) end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
80 81 82 |
# File 'lib/natty-ui/table_renderer.rb', line 80 def text @text end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
80 81 82 |
# File 'lib/natty-ui/table_renderer.rb', line 80 def width @width end |
Instance Method Details
#correct_height(height) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/natty-ui/table_renderer.rb', line 82 def correct_height(height) return self if (diff = height - @text.size) <= 0 @text = case @vertical when :bottom [Array.new(diff, @empty), @text] when :middle tc = diff / 2 [Array.new(tc, @empty), @text, Array.new(diff - tc, @empty)] else [@text, Array.new(diff, @empty)] end.flatten(1) self end |