Class: Doing::TemplateString
- Includes:
- Color
- Defined in:
- lib/doing/template_string.rb
Overview
Template string formatting
Constant Summary
Constants included from Color
Color::ATTRIBUTES, Color::ATTRIBUTE_NAMES, Color::COLORED_REGEXP
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
-
#apply_colors(color_array) ⇒ Object
Apply a color array to a string.
-
#colored ⇒ String
Return string with %colors replaced with escape codes.
-
#colors? ⇒ Boolean
Test if string contains any valid %colors.
- #fill(placeholder, value, wrap_width: 0, color: '', tags_color: '', reset: '') ⇒ Object
-
#initialize(string, placeholders: {}, force_color: false, wrap_width: 0, color: '', tags_color: '', reset: '') ⇒ TemplateString
constructor
A new instance of TemplateString.
-
#parse_colors ⇒ Hash
Parse a template string for %colors and return a hash of colors and string locations.
- #parsed_colors ⇒ Object
-
#raw ⇒ String
Remove all valid %colors from string.
- #reparse ⇒ Object
Methods included from Color
#attributes, coloring?, #support?, template, #uncolor
Methods inherited from String
#good?, #normalize_color, #sanitize, #utf8, #valid_id?, #validate_color
Methods included from Completion::StringUtils
#ltrunc, #ltrunc!, #short_desc
Methods included from ChronifyString
#chronify, #chronify_qty, #expand_date_tags, #is_range?, #split_date_range, #time_string, #to_seconds
Methods included from StringURL
#clean_unlinked_urls, #link_urls, #link_urls!, #remove_self_links, #replace_qualified_urls
Methods included from StringTruncate
#trunc, #trunc!, #truncend, #truncend!, #truncmiddle, #truncmiddle!
Methods included from StringTransform
#cap_first, #compress, #compress!, #set_type, #simple_wrap, #titlecase, #to_p, #wrap
Methods included from StringTags
#add_at, #add_tags, #add_tags!, #dedup_tags, #dedup_tags!, #remove_at, #split_tags, #tag, #tag!, #to_tags
Methods included from StringQuery
#ignore?, #ignore_case, #rx?, #to_bool, #to_phrase_query, #to_query, #to_rx, #truthy?, #wildcard_to_rx
Methods included from StringHighlight
#highlight_search, #highlight_search!, #highlight_tags, #highlight_tags!, #last_color, #uncolor, #uncolor!
Methods included from StringNormalize
#normalize_age, #normalize_age!, #normalize_bool, #normalize_bool!, #normalize_case, #normalize_case!, #normalize_change_type, #normalize_matching, #normalize_matching!, #normalize_order, #normalize_order!, #normalize_tag_sort, #normalize_tag_sort!, #normalize_trigger, #normalize_trigger!
Constructor Details
#initialize(string, placeholders: {}, force_color: false, wrap_width: 0, color: '', tags_color: '', reset: '') ⇒ TemplateString
Returns a new instance of TemplateString.
Instance Attribute Details
#original ⇒ Object (readonly)
Returns the value of attribute original.
Instance Method Details
#apply_colors(color_array) ⇒ Object
Apply a color array to a string
#colored ⇒ String
Return string with %colors replaced with escape codes
#colors? ⇒ Boolean
Test if string contains any valid %colors
#fill(placeholder, value, wrap_width: 0, color: '', tags_color: '', reset: '') ⇒ Object
#parse_colors ⇒ Hash
Parse a template string for %colors and return a hash of colors and string locations
#parsed_colors ⇒ Object
#raw ⇒ String
Remove all valid %colors from string