Class: MarkdownTable::AlignRow
- Inherits:
-
Object
- Object
- MarkdownTable::AlignRow
- Defined in:
- lib/markdown_table/align_row.rb
Constant Summary collapse
- ALIGNS =
{ normal: '-', center: ':-:', left: ':-', right: '-:' }.freeze
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(size:, align: []) ⇒ AlignRow
constructor
A new instance of AlignRow.
Constructor Details
#initialize(size:, align: []) ⇒ AlignRow
Returns a new instance of AlignRow.
14 15 16 17 |
# File 'lib/markdown_table/align_row.rb', line 14 def initialize(size:, align: []) @size = size @align = align end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
5 6 7 |
# File 'lib/markdown_table/align_row.rb', line 5 def align @align end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
5 6 7 |
# File 'lib/markdown_table/align_row.rb', line 5 def size @size end |
Instance Method Details
#generate ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/markdown_table/align_row.rb', line 19 def generate algin_row = Array.new(@size, ALIGNS[:normal]) @align.each_with_index do |value, key| next if ALIGNS[value].nil? next if algin_row[key].nil? algin_row[key] = ALIGNS[value] end "|#{algin_row.join('|')}|\n" end |