Class: HammerCLI::Output::Formatters::FormatterContainer

Inherits:
FieldFormatter
  • Object
show all
Defined in:
lib/hammer_cli/output/formatters.rb

Instance Method Summary collapse

Methods inherited from FieldFormatter

inherited, #match?, #required_features, #tags

Constructor Details

#initialize(*formatters) ⇒ FormatterContainer

Returns a new instance of FormatterContainer.



62
63
64
# File 'lib/hammer_cli/output/formatters.rb', line 62

def initialize(*formatters)
  @formatters = formatters
end

Instance Method Details

#add_formatter(*formatters) ⇒ Object



66
67
68
# File 'lib/hammer_cli/output/formatters.rb', line 66

def add_formatter(*formatters)
  @formatters += formatters
end

#format(data, field_params = {}) ⇒ Object



70
71
72
# File 'lib/hammer_cli/output/formatters.rb', line 70

def format(data, field_params={})
  @formatters.inject(data) { |d,f| f.format(d, field_params) }
end