Module: Doing::StringTags

Included in:
String
Defined in:
lib/doing/string/tags.rb

Overview

Handling of @tags in strings

Instance Method Summary collapse

Instance Method Details

#add_at ⇒ String

Add @ prefix to string if needed, maintains +/- prefix

Returns:

#add_tags(tags, remove: false) ⇒ String

Adds tags to a string

Parameters:

  • tags (String or Array) —

    List of tags to add. @ symbol optional

  • remove (Boolean) (defaults to: false) —

    remove tags instead of adding

Returns:

  • (String) —

    the tagged string

#add_tags!(tags, remove: false) ⇒ Object

See Also:

#dedup_tags ⇒ Object

Remove duplicate tags, leaving only first occurrence

Returns:

  • Deduplicated string

#dedup_tags! ⇒ Object

See Also:

#remove_at ⇒ String

Removes @ prefix if needed, maintains +/- prefix

Returns:

  • (String) —

    string without @ prefix

#split_tags ⇒ Array

Split a string of tags, remove @ symbols, with or without @ symbols, with or without parenthetical values

Returns:

  • (Array) —

    array of tags without @ symbols

#tag(tag, value: nil, remove: false, rename_to: nil, regex: false, single: false, force: false) ⇒ String

Add, rename, or remove a tag

Parameters:

  • tag —

    The tag

  • value (String) (defaults to: nil) —

    Value for tag (@tag(value))

  • remove (Boolean) (defaults to: false) —

    Remove the tag instead of adding

  • rename_to (String) (defaults to: nil) —

    Replace tag with this tag

  • regex (Boolean) (defaults to: false) —

    Tag is regular expression

  • single (Boolean) (defaults to: false) —

    Operating on a single item (for logging)

  • force (Boolean) (defaults to: false) —

    With rename_to, add tag if it doesn't exist

Returns:

  • (String) —

    The string with modified tags

#tag!(tag, **options) ⇒ Object

Add, rename, or remove a tag in place

See Also:

#to_tags ⇒ Array

Convert a list of tags to an array. Tags can be with or without @ symbols, separated by any character, and can include parenthetical values (with spaces)

Returns:

  • (Array) —

    array of tags including @ symbols