Class: Argh::Formatters::BaseFormatter
- Inherits:
-
Object
- Object
- Argh::Formatters::BaseFormatter
- Defined in:
- lib/argh/formatters/base_formatter.rb
Direct Known Subclasses
Instance Method Summary collapse
- #attributes(&block) ⇒ Object
-
#initialize(collector, context) ⇒ BaseFormatter
constructor
A new instance of BaseFormatter.
- #process ⇒ Object
Constructor Details
#initialize(collector, context) ⇒ BaseFormatter
Returns a new instance of BaseFormatter.
6 7 8 9 |
# File 'lib/argh/formatters/base_formatter.rb', line 6 def initialize(collector, context) @collector = collector @context = context end |
Instance Method Details
#attributes(&block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/argh/formatters/base_formatter.rb', line 11 def attributes(&block) return enum_for(:attributes) unless block_given? @collector.attributes.each do |attr| value = @context.instance_eval(&attr[:lambda]) yield attr[:name], value end end |
#process ⇒ Object
19 20 21 |
# File 'lib/argh/formatters/base_formatter.rb', line 19 def process raise 'BaseFormatter should be subclassed' end |