Class: String
- Inherits:
-
Object
- Object
- String
- Includes:
- Doing::Color
- Defined in:
- lib/doing/string.rb,
lib/doing/string_chronify.rb
Overview
Chronify methods for strings
Constant Summary
Constants included from Doing::Color
Doing::Color::ATTRIBUTES, Doing::Color::ATTRIBUTE_NAMES, Doing::Color::COLORED_REGEXP
Instance Method Summary collapse
- #add_tags(tags, remove: false) ⇒ Object
- #add_tags!(tags, remove: false) ⇒ Object
-
#cap_first ⇒ Object
Capitalize on the first character on string.
-
#chronify(**options) ⇒ DateTime
Converts input string into a Time object when input takes on the following formats: - interval format e.g.
-
#chronify_qty ⇒ Integer
Converts simple strings into seconds that can be added to a Time object.
-
#clean_unlinked_urls ⇒ Object
Clean up unlinked
. -
#compress ⇒ Object
Compress multiple spaces to single space.
- #compress! ⇒ Object
- #dedup_tags ⇒ Object
-
#dedup_tags! ⇒ Object
Remove duplicate tags, leaving only first occurrence.
-
#highlight_tags(color = 'yellow') ⇒ String
Colorize @tags with ANSI escapes.
- #highlight_tags!(color = 'yellow') ⇒ Object
-
#ignore? ⇒ Boolean
Test if line should be ignored.
-
#is_rx? ⇒ Boolean
Determines if receiver is surrounded by slashes or starts with single quote.
-
#last_color ⇒ String
Returns the last escape sequence from a string.
- #link_urls(**opt) ⇒ Object
-
#link_urls!(**opt) ⇒ Object
Turn raw urls into HTML links.
- #normalize_bool(default = :and) ⇒ Object
-
#normalize_bool!(default = :and) ⇒ Object
Convert a boolean string to a symbol.
- #normalize_case(default = :smart) ⇒ Object
-
#normalize_case! ⇒ Object
Convert a case sensitivity string to a symbol.
- #normalize_order(default = 'asc') ⇒ Object
-
#normalize_order!(default = 'asc') ⇒ String
Convert a sort order string to a qualified type.
- #normalize_trigger ⇒ Object
- #normalize_trigger! ⇒ Object
-
#remove_self_links ⇒ Object
Remove
formatting. -
#replace_qualified_urls(**options) ⇒ Object
Replace qualified urls.
- #set_type(kind = nil) ⇒ Object
-
#tag(tag, value: nil, remove: false, rename_to: nil, regex: false, single: false, force: false) ⇒ String
Add, rename, or remove a tag.
-
#tag!(tag, **options) ⇒ Object
Add, rename, or remove a tag in place.
-
#to_rx(distance: 3, case_type: :smart) ⇒ Regexp
Convert string to fuzzy regex.
- #to_tags ⇒ Object
-
#truncate(len, ellipsis: '...') ⇒ Object
Truncate to nearest word.
- #truncate!(len, ellipsis: '...') ⇒ Object
-
#truncmiddle(len, ellipsis: '...') ⇒ Object
Truncate string in the middle.
- #truncmiddle!(len, ellipsis: '...') ⇒ Object
-
#truthy? ⇒ Boolean
Test string for truthiness (0, "f", "false", "n", "no" all return false, case insensitive, otherwise true).
-
#uncolor ⇒ Object
Remove color escape codes.
- #uncolor! ⇒ Object
-
#wrap(len, pad: 0, indent: ' ', offset: 0, prefix: '', color: '', after: '', reset: '') ⇒ Object
Wrap string at word breaks, respecting tags.
Methods included from Doing::Color
attributes, coloring?, #support?
Instance Method Details
#add_tags(tags, remove: false) ⇒ Object
#add_tags!(tags, remove: false) ⇒ Object
#cap_first ⇒ Object
Capitalize on the first character on string
#chronify(**options) ⇒ DateTime
Converts input string into a Time object when input takes on the following formats: - interval format e.g. '1d2h30m', '45m' etc. - a semantic phrase e.g. 'yesterday 5:30pm' - a strftime e.g. '2016-03-15 15:32:04 PDT'
#chronify_qty ⇒ Integer
Converts simple strings into seconds that can be added to a Time object
Input string can be HH:MM or XX[dhm][XXhm][XXm]
#clean_unlinked_urls ⇒ Object
Clean up unlinked
#compress ⇒ Object
Compress multiple spaces to single space
#compress! ⇒ Object
#dedup_tags ⇒ Object
#dedup_tags! ⇒ Object
Remove duplicate tags, leaving only first occurrence
#highlight_tags(color = 'yellow') ⇒ String
Colorize @tags with ANSI escapes
#highlight_tags!(color = 'yellow') ⇒ Object
#ignore? ⇒ Boolean
Test if line should be ignored
#is_rx? ⇒ Boolean
Determines if receiver is surrounded by slashes or starts with single quote
#last_color ⇒ String
Returns the last escape sequence from a string.
Actually returns all escape codes, with the assumption that the result of inserting them will generate the same color as was set at the end of the string. Because you can send modifiers like dark and bold separate from color codes, only using the last code may not render the same style.
#link_urls(**opt) ⇒ Object
#link_urls!(**opt) ⇒ Object
Turn raw urls into HTML links
#normalize_bool(default = :and) ⇒ Object
#normalize_bool!(default = :and) ⇒ Object
Convert a boolean string to a symbol
#normalize_case(default = :smart) ⇒ Object
#normalize_case! ⇒ Object
Convert a case sensitivity string to a symbol
#normalize_order(default = 'asc') ⇒ Object
#normalize_order!(default = 'asc') ⇒ String
Convert a sort order string to a qualified type
#normalize_trigger ⇒ Object
#normalize_trigger! ⇒ Object
#remove_self_links ⇒ Object
Remove
#replace_qualified_urls(**options) ⇒ Object
Replace qualified urls
#set_type(kind = nil) ⇒ Object
#tag(tag, value: nil, remove: false, rename_to: nil, regex: false, single: false, force: false) ⇒ String
Add, rename, or remove a tag
#tag!(tag, **options) ⇒ Object
Add, rename, or remove a tag in place
#to_rx(distance: 3, case_type: :smart) ⇒ Regexp
Convert string to fuzzy regex. Characters in words can be separated by up to distance characters in haystack, spaces indicate unlimited distance.
#to_tags ⇒ Object
#truncate(len, ellipsis: '...') ⇒ Object
Truncate to nearest word
#truncate!(len, ellipsis: '...') ⇒ Object
#truncmiddle(len, ellipsis: '...') ⇒ Object
Truncate string in the middle
#truncmiddle!(len, ellipsis: '...') ⇒ Object
#truthy? ⇒ Boolean
Test string for truthiness (0, "f", "false", "n", "no" all return false, case insensitive, otherwise true)
#uncolor ⇒ Object
Remove color escape codes
#uncolor! ⇒ Object
#wrap(len, pad: 0, indent: ' ', offset: 0, prefix: '', color: '', after: '', reset: '') ⇒ Object
Wrap string at word breaks, respecting tags