Class: HammerCLI::Output::Formatters::LongTextFormatter

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

Constant Summary collapse

INDENT =
"  "

Instance Method Summary collapse

Methods inherited from FieldFormatter

inherited, #match?, #tags

Constructor Details

#initialize(options = {}) ⇒ LongTextFormatter

Returns a new instance of LongTextFormatter.



156
157
158
# File 'lib/hammer_cli/output/formatters.rb', line 156

def initialize(options = {})
  @indent = options[:indent].nil? ? true : options[:indent]
end

Instance Method Details

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



166
167
168
169
# File 'lib/hammer_cli/output/formatters.rb', line 166

def format(text, field_params={})
  text = text.to_s.indent_with(INDENT) if @indent
  "\n#{text}"
end

#required_featuresObject



160
161
162
163
164
# File 'lib/hammer_cli/output/formatters.rb', line 160

def required_features
  return %i[rich_text] if tags.empty?

  tags.map { |t| HammerCLI::Output::Utils.tag_to_feature(t) }
end