Class: Argh::Formatters::BaseFormatter

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

Direct Known Subclasses

JCommanderFormatter

Instance Method Summary collapse

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

#processObject



19
20
21
# File 'lib/argh/formatters/base_formatter.rb', line 19

def process
  raise 'BaseFormatter should be subclassed'
end