Class: Argh::Collector
- Inherits:
-
Object
- Object
- Argh::Collector
- Defined in:
- lib/argh/collector.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #attribute(name, attribute = nil, &block) ⇒ Object
-
#initialize(&block) ⇒ Collector
constructor
A new instance of Collector.
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
#attributes ⇒ Object (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 |