Class: Tabl::Column
- Inherits:
-
Object
- Object
- Tabl::Column
- Defined in:
- lib/tabl/column.rb
Defined Under Namespace
Classes: Formats
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
- #value(record) ⇒ Object
Instance Method Summary collapse
- #format(name = nil) ⇒ Object
-
#initialize(name, args = {}) {|_self| ... } ⇒ Column
constructor
A new instance of Column.
Constructor Details
#initialize(name, args = {}) {|_self| ... } ⇒ Column
Returns a new instance of Column.
7 8 9 10 11 12 13 |
# File 'lib/tabl/column.rb', line 7 def initialize(name, args = {}) @name = name @label = args[:label] || @name.to_s.titleize @value = args[:value] || lambda { |record| record.send(@name) } @formats = Formats.new yield self if block_given? end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
4 5 6 |
# File 'lib/tabl/column.rb', line 4 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/tabl/column.rb', line 3 def name @name end |
#value(record) ⇒ Object
15 16 17 |
# File 'lib/tabl/column.rb', line 15 def value(record) @value.call(record) end |
Instance Method Details
#format(name = nil) ⇒ Object
19 20 21 |
# File 'lib/tabl/column.rb', line 19 def format(name = nil) @formats end |