Sha256: 75f84f59b7936ef13d74836e56750cf4069b24da037ba2eb7419e7659f6c36e6
Contents?: true
Size: 981 Bytes
Versions: 4
Compression:
Stored size: 981 Bytes
Contents
require 'report/body/column' require 'report/body/row' class Report class Body attr_reader :table attr_reader :columns attr_reader :method_id attr_reader :method_args def initialize(table) @table = table @columns = [] end def rows(*args) @method_id = args.shift if args.last.is_a?(Array) @method_args = args.last end end def column(*args, &blk) @columns << Column.new(*([self]+args), &blk) end def each(report) block_taken = false if method_args enum = report.send(method_id, *method_args) do |obj| block_taken = true yield Row.new(self, report, obj) end else enum = report.send(method_id) do |obj| block_taken = true yield Row.new(self, report, obj) end end unless block_taken enum.each do |obj| yield Row.new(self, report, obj) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
report-0.1.1 | lib/report/body.rb |
report-0.1.0 | lib/report/body.rb |
report-0.0.3 | lib/report/body.rb |
report-0.0.2 | lib/report/body.rb |