Class: Text::Gen::Filter::Titleize

Inherits:
Base
  • Object
show all
Defined in:
lib/text/gen/filter/titleize.rb

Constant Summary collapse

SKIP_WORDS =
Set.new(%w[a an and as at but by for if in of on or the to v via vs])

Instance Method Summary collapse

Methods inherited from Base

#component_key, filter_key, filter_name, #initialize, #key, #to_s, #type, #value

Constructor Details

This class inherits a constructor from Text::Gen::Filter::Base

Instance Method Details

#result(context, result) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/text/gen/filter/titleize.rb', line 9

def result(context, result)
  return result if @depth && context.depth != @depth

  text = result.text
  text = titleize(text)
  return result if text == result.text

  Result.from(result, text:, type: component_key)
end