Class: AxlsxReport::Column
- Inherits:
-
Object
- Object
- AxlsxReport::Column
- Defined in:
- lib/axlsx_report/column.rb
Overview
Report’s column representation
Instance Attribute Summary collapse
-
#callable ⇒ Object
readonly
Returns the value of attribute callable.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(name, callable, options = {}) ⇒ Column
constructor
Creates new column.
-
#value(report, obj) ⇒ Object
Calculates column value for given object.
Constructor Details
#initialize(name, callable, options = {}) ⇒ Column
Creates new column
16 17 18 |
# File 'lib/axlsx_report/column.rb', line 16 def initialize(name, callable, = {}) @name, @callable, = name, callable, end |
Instance Attribute Details
#callable ⇒ Object (readonly)
Returns the value of attribute callable.
4 5 6 |
# File 'lib/axlsx_report/column.rb', line 4 def callable @callable end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/axlsx_report/column.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/axlsx_report/column.rb', line 4 def end |
Instance Method Details
#value(report, obj) ⇒ Object
Calculates column value for given object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/axlsx_report/column.rb', line 32 def value(report, obj) source = extract_source(obj) return nil if source.nil? value = if callable.arity.zero? source.instance_exec &callable else report.instance_exec source, &callable end transform = [:transform] value = report.send transform, value if transform value end |