Class: Text::Gen::Filter::Capitalize
- Defined in:
- lib/text/gen/filter/capitalize.rb
Overview
Capitalize the result text; first character only by default. Use ‘capitalize:force` to use the default ruby `capitalize` method
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/capitalize.rb', line 9 def result(context, result) return result if @depth && context.depth != @depth text = result.text text = key == "force" ? text.capitalize : text.sub(/\S/, &:upcase) return result if text == result.text Result.from(result, text:, type: component_key) end |