Class: Noventius::Column
- Inherits:
-
Object
- Object
- Noventius::Column
- Defined in:
- lib/noventius/column.rb
Constant Summary collapse
- TYPES =
%i(string integer float datetime date)
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #depth ⇒ Object
-
#html_options ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity.
-
#initialize(name, type, options = {}) ⇒ Column
constructor
rubocop:disable Metrics/CyclomaticComplexity.
- #value(report, row) ⇒ Object
Constructor Details
#initialize(name, type, options = {}) ⇒ Column
rubocop:disable Metrics/CyclomaticComplexity
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/noventius/column.rb', line 10 def initialize(name, type, = {}) fail ArgumentError, "ColumnType: [#{type}] not yet implemented." unless TYPES.include?(type.to_sym) @name = name.to_sym @type = type.to_sym @label = .delete(:label) || @name.to_s @label = instance_exec(&@label) if @label.is_a?(Proc) @default_value = [:default_value] || default_value_for_type @value = [:value] || default_value_block(@name, @default_value) @options = @children = [:children] || [] end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/noventius/column.rb', line 7 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/noventius/column.rb', line 7 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/noventius/column.rb', line 7 def type @type end |
Instance Method Details
#depth ⇒ Object
38 39 40 |
# File 'lib/noventius/column.rb', line 38 def depth 1 end |
#html_options ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity
24 25 26 |
# File 'lib/noventius/column.rb', line 24 def @options[:html_options] || {} end |
#value(report, row) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/noventius/column.rb', line 28 def value(report, row) if @value.is_a?(Proc) report.instance_exec(row, &@value) elsif @value.is_a?(Symbol) report.public_send(@value, row) else @value end end |