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?, #uncolor
Methods inherited from String
#add_at, #add_tags, #add_tags!, #cap_first, #chronify, #chronify_qty, #clean_unlinked_urls, #compress, #compress!, #dedup_tags, #dedup_tags!, #expand_date_tags, #highlight_search, #highlight_search!, #highlight_tags, #highlight_tags!, #ignore?, #ignore_case, #is_range?, #is_rx?, #last_color, #link_urls, #link_urls!, #normalize_age, #normalize_age!, #normalize_bool, #normalize_bool!, #normalize_case, #normalize_case!, #normalize_matching, #normalize_matching!, #normalize_order, #normalize_order!, #normalize_trigger, #normalize_trigger!, #remove_at, #remove_self_links, #replace_qualified_urls, #set_type, #simple_wrap, #split_date_range, #tag, #tag!, #time_string, #to_bool, #to_p, #to_phrase_query, #to_query, #to_rx, #to_seconds, #to_tags, #truncate, #truncate!, #truncmiddle, #truncmiddle!, #truthy?, #uncolor, #uncolor!, #validate_color, #wildcard_to_rx, #wrap
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