Class: Samovar::Output::Row
- Inherits:
-
Array
- Object
- Array
- Samovar::Output::Row
- Defined in:
- lib/samovar/output/row.rb
Overview
Represents a row in usage output.
Rows display formatted option or argument information with proper column alignment.
Instance Attribute Summary collapse
-
#object ⇒ Object
The source object for this row.
Instance Method Summary collapse
-
#align(columns) ⇒ Object
Generate an aligned row string.
-
#initialize(object) ⇒ Row
constructor
Initialize a new row.
Constructor Details
#initialize(object) ⇒ Row
Initialize a new row.
15 16 17 18 |
# File 'lib/samovar/output/row.rb', line 15 def initialize(object) @object = object super object.to_a.collect(&:to_s) end |
Instance Attribute Details
#object ⇒ Object
The source object for this row.
23 24 25 |
# File 'lib/samovar/output/row.rb', line 23 def object @object end |
Instance Method Details
#align(columns) ⇒ Object
Generate an aligned row string.
29 30 31 32 33 |
# File 'lib/samovar/output/row.rb', line 29 def align(columns) self.collect.with_index do |value, index| value.ljust(columns.widths[index]) end.join(" ") end |