Class: Argh::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/argh/collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Collector

Returns a new instance of Collector.



7
8
9
10
# File 'lib/argh/collector.rb', line 7

def initialize(&block)
  @attributes = []
  instance_eval(&block)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/argh/collector.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#attribute(name, attribute = nil, &block) ⇒ Object



12
13
14
15
16
17
# File 'lib/argh/collector.rb', line 12

def attribute(name, attribute = nil, &block)
  @attributes << {
    :name => name,
    :lambda => block || lambda { |i| i.send(attribute || name) }
  }
end