Class: Csb::Col
- Inherits:
-
Object
- Object
- Csb::Col
- Defined in:
- lib/csb/col.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, value = nil, &block) ⇒ Col
constructor
A new instance of Col.
- #value_by_item(item) ⇒ Object
Constructor Details
#initialize(name, value = nil, &block) ⇒ Col
Returns a new instance of Col.
5 6 7 8 |
# File 'lib/csb/col.rb', line 5 def initialize(name, value = nil, &block) @name = name @value = block ? block : value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/csb/col.rb', line 3 def name @name end |
Instance Method Details
#value_by_item(item) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/csb/col.rb', line 10 def value_by_item(item) case value when ::Symbol item.public_send(value) when ::Proc value.call(item) else value end end |