Class: Doing::TemplateString

Inherits:
String show all
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

Instance Method Summary collapse

Methods included from Color

attributes, coloring?, #support?, #uncolor

Methods inherited from String

#good?, #normalize_age, #normalize_age!, #normalize_bool, #normalize_bool!, #normalize_case, #normalize_case!, #normalize_color, #normalize_matching, #normalize_matching!, #normalize_order, #normalize_order!, #normalize_tag_sort, #normalize_tag_sort!, #normalize_trigger, #normalize_trigger!, #validate_color

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

#originalObject (readonly)

Returns the value of attribute original.

Instance Method Details

#apply_colors(color_array) ⇒ Object

Apply a color array to a string

Parameters:

  • color_array (Array)

    Array of hashes containing :name, :color, :index

#coloredString

Return string with %colors replaced with escape codes

Returns:

  • (String)

    colorized string

#colors?Boolean

Test if string contains any valid %colors

Returns:

  • (Boolean)

    True if colors, False otherwise.

#fill(placeholder, value, wrap_width: 0, color: '', tags_color: '', reset: '') ⇒ Object

#parse_colorsHash

Parse a template string for %colors and return a hash of colors and string locations

Returns:

  • (Hash)

    Uncolored string and array of colors and locations

#parsed_colorsObject

#rawString

Remove all valid %colors from string

Returns:

#reparseObject