Class: Report::Body
- Inherits:
-
Object
- Object
- Report::Body
- Defined in:
- lib/report/body.rb,
lib/report/body/row.rb,
lib/report/body/column.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#method_args ⇒ Object
readonly
Returns the value of attribute method_args.
-
#method_id ⇒ Object
readonly
Returns the value of attribute method_id.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #column(*args, &blk) ⇒ Object
- #each(report) ⇒ Object
-
#initialize(table) ⇒ Body
constructor
A new instance of Body.
- #rows(*args) ⇒ Object
Constructor Details
#initialize(table) ⇒ Body
Returns a new instance of Body.
10 11 12 13 |
# File 'lib/report/body.rb', line 10 def initialize(table) @table = table @columns = [] end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
7 8 9 |
# File 'lib/report/body.rb', line 7 def columns @columns end |
#method_args ⇒ Object (readonly)
Returns the value of attribute method_args.
9 10 11 |
# File 'lib/report/body.rb', line 9 def method_args @method_args end |
#method_id ⇒ Object (readonly)
Returns the value of attribute method_id.
8 9 10 |
# File 'lib/report/body.rb', line 8 def method_id @method_id end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
6 7 8 |
# File 'lib/report/body.rb', line 6 def table @table end |
Instance Method Details
#column(*args, &blk) ⇒ Object
20 21 22 |
# File 'lib/report/body.rb', line 20 def column(*args, &blk) @columns << Column.new(*([self]+args), &blk) end |
#each(report) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/report/body.rb', line 23 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 |
#rows(*args) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/report/body.rb', line 14 def rows(*args) @method_id = args.shift if args.last.is_a?(Array) @method_args = args.last end end |