Class: String

Inherits:
Object
  • Object
show all
Includes:
Doing::Color
Defined in:
lib/doing/string.rb

Overview

String helpers

Constant Summary

Constants included from Doing::Color

Doing::Color::ATTRIBUTES, Doing::Color::ATTRIBUTE_NAMES, Doing::Color::COLORED_REGEXP

Instance Method Summary collapse

Methods included from Doing::Color

attributes, coloring=, coloring?, #support?

Instance Method Details

#add_tags(tags, remove: false) ⇒ Object

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

#cap_firstObject

Capitalize on the first character on string

Returns:

  • Capitalized string

#dedup_tagsObject

#dedup_tags!Object

Remove duplicate tags, leaving only first occurrence

Returns:

  • Deduplicated string

#highlight_tags(color = 'yellow') ⇒ String

Colorize @tags with ANSI escapes

Parameters:

  • color (String) (defaults to: 'yellow')

    color (see #Color)

Returns:

  • (String)

    string with @tags highlighted

#highlight_tags!(color = 'yellow') ⇒ Object

Parameters:

  • color (String) (defaults to: 'yellow')

    color (see #Color)

#ignore?Boolean

Test if line should be ignored

Returns:

  • (Boolean)

    line is empty or comment

Turn raw urls into HTML links

Parameters:

  • opt (Hash) (defaults to: {})

    Additional Options

#normalize_bool(default = :and) ⇒ Object

#normalize_bool!(default = :and) ⇒ Object

Convert a boolean string to a symbol

Returns:

  • Symbol :and, :or, or :not

#normalize_case(default = :smart) ⇒ Object

#normalize_case!Object

Convert a case sensitivity string to a symbol

Returns:

  • Symbol :smart, :sensitive, :insensitive

#normalize_order(default = 'asc') ⇒ Object

#normalize_order!(default = 'asc') ⇒ String

Convert a sort order string to a qualified type

Returns:

  • (String)

    'asc' or 'desc'

#normalize_triggerObject

#normalize_trigger!Object

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

#tag!(tag, value: nil, remove: false, rename_to: nil, regex: false, single: false) ⇒ Object

#to_rx(distance) ⇒ String

Convert string to fuzzy regex

Parameters:

  • distance (Integer)

    Allowed distance between characters

Returns:

#to_tagsObject

#truncate(len, ellipsis: '...') ⇒ Object

Truncate to nearest word

Parameters:

  • len

    The length

#truncate!(len, ellipsis: '...') ⇒ Object

#truncmiddle(len, ellipsis: '...') ⇒ Object

Truncate string in the middle

Parameters:

  • len

    The length

  • ellipsis (defaults to: '...')

    The ellipsis

#truncmiddle!(len, ellipsis: '...') ⇒ Object

#truthy?Boolean

Test string for truthiness (0, "f", "false", "n", "no" all return false, case insensitive, otherwise true)

Returns:

  • (Boolean)

    String is truthy

#uncolorObject

Remove color escape codes

Returns:

  • clean string

#uncolor!Object

#wrap(len, pad: 0, indent: ' ', offset: 0, prefix: '', after: '', reset: '') ⇒ Object

Wrap string at word breaks, respecting tags

Parameters:

  • len (Integer)

    The length

  • offset (Integer) (defaults to: 0)

    (Optional) The width to pad each subsequent line

  • prefix (String) (defaults to: '')

    (Optional) A prefix to add to each line