class Samovar::Output::Rows
Attributes
level[R]
Public Class Methods
new(level = 0)
click to toggle source
# File lib/samovar/output/rows.rb, line 15 def initialize(level = 0) @level = level @rows = [] end
Public Instance Methods
<<(object)
click to toggle source
# File lib/samovar/output/rows.rb, line 50 def << object @rows << Row.new(object) return self end
columns()
click to toggle source
# File lib/samovar/output/rows.rb, line 56 def columns @columns ||= Columns.new(@rows.select{|row| row.is_a? Array}) end
each(ignore_nested: false) { |row, self| ... }
click to toggle source
# File lib/samovar/output/rows.rb, line 38 def each(ignore_nested: false, &block) return to_enum(:each, ignore_nested: ignore_nested) unless block_given? @rows.each do |row| if row.is_a?(self.class) row.each(&block) unless ignore_nested else yield row, self end end end
empty?()
click to toggle source
# File lib/samovar/output/rows.rb, line 22 def empty? @rows.empty? end
first()
click to toggle source
# File lib/samovar/output/rows.rb, line 26 def first @rows.first end
indentation()
click to toggle source
# File lib/samovar/output/rows.rb, line 34 def indentation @indentation ||= "\t" * @level end
last()
click to toggle source
# File lib/samovar/output/rows.rb, line 30 def last @rows.last end
nested(*arguments) { |nested_rows| ... }
click to toggle source
# File lib/samovar/output/rows.rb, line 60 def nested(*arguments) @rows << Header.new(*arguments) nested_rows = self.class.new(@level + 1) yield nested_rows @rows << nested_rows end