Class: UDRS::Components::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/udrs/components/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, *args, &block) ⇒ Row

Returns a new instance of Row.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/udrs/components/table.rb', line 52

def initialize(table, *args, &block)
	options = {}
	options = args.pop if args.last.is_a?(Hash)

	@cells = []
	args.each { |c| cell(c, options) }
	block.call(self) if block

	if @cells.size != table.columns.size
		fail ArgumentError, "Row contains #{cells.size} cells, but #{table.columns.size} are required"
	end
end

Instance Attribute Details

#cellsObject (readonly)

Returns the value of attribute cells.



50
51
52
# File 'lib/udrs/components/table.rb', line 50

def cells
  @cells
end

Instance Method Details

#cell(text, options = {}) ⇒ Object



65
66
67
# File 'lib/udrs/components/table.rb', line 65

def cell(text, options = {})
	@cells << Text.new(text, options)
end