Class: Reportabull::Column
- Inherits:
-
Object
- Object
- Reportabull::Column
- Defined in:
- lib/reportabull/column.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #humanize_name(name, humanize_name_option) ⇒ Object
-
#initialize(name, options = {}, block = nil) ⇒ Column
constructor
A new instance of Column.
- #value(resource) ⇒ Object
Constructor Details
#initialize(name, options = {}, block = nil) ⇒ Column
Returns a new instance of Column.
7 8 9 10 11 12 |
# File 'lib/reportabull/column.rb', line 7 def initialize(name, = {}, block = nil) = [:humanize_name] = true if [:humanize_name].nil? @name = humanize_name(name, [:humanize_name]) @data = block || name.to_sym end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/reportabull/column.rb', line 5 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/reportabull/column.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/reportabull/column.rb', line 5 def end |
Instance Method Details
#humanize_name(name, humanize_name_option) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/reportabull/column.rb', line 14 def humanize_name(name, humanize_name_option) if humanize_name_option name.to_s.humanize else name.to_s end end |
#value(resource) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/reportabull/column.rb', line 22 def value(resource) case data when Symbol, String resource.send(data) when Proc resource.instance_exec(resource, &data) end end |