Class: TableCloth::Column
- Inherits:
-
Object
- Object
- TableCloth::Column
- Defined in:
- lib/table_cloth/column.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #human_name(view) ⇒ Object
-
#initialize(name, options = {}) ⇒ Column
constructor
A new instance of Column.
- #value(object, view, table = nil) ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Column
Returns a new instance of Column.
5 6 7 8 |
# File 'lib/table_cloth/column.rb', line 5 def initialize(name, ={}) @name = name @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/table_cloth/column.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/table_cloth/column.rb', line 3 def @options end |
Instance Method Details
#human_name(view) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/table_cloth/column.rb', line 18 def human_name(view) if [:label].kind_of? Proc view.instance_exec(&[:label]) else [:label] || name.to_s.humanize end end |
#value(object, view, table = nil) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/table_cloth/column.rb', line 10 def value(object, view, table=nil) if [:proc].respond_to?(:call) view.instance_exec(object, view, &[:proc]) else object.send(name) end end |