Class: Samovar::Output::Row

Inherits:
Array
  • Object
show all
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

Instance Method Summary collapse

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

#objectObject

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