Class: Csb::Col

Inherits:
Object
  • Object
show all
Defined in:
lib/csb/col.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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