Module: Doing::StringTransform

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

Overview

String helpers

Instance Method Summary collapse

Instance Method Details

#cap_firstObject

Capitalize on the first character on string

Returns:

  • Capitalized string

#compressObject

Compress multiple spaces to single space

#compress!Object

#set_type(kind = nil) ⇒ Object

Convert a string value to an appropriate type. If kind is not specified, '[one, two]' becomes an Array, '1' becomes Integer, '1.5' becomes Float, 'true' or 'yes' becomes TrueClass, 'false' or 'no' becomes FalseClass.

Parameters:

  • kind (String) (defaults to: nil)

    specify string, array, integer, float, symbol, or boolean (falls back to string if value is not recognized)

Returns:

  • Converted object type

#simple_wrap(width) ⇒ Object

#titlecaseObject

#to_p(number) ⇒ Object

Pluralize a string based on quantity

Parameters:

  • number (Integer)

    the quantity of the object the string represents

#wrap(len, pad: 0, indent: ' ', offset: 0, prefix: '', color: '', after: '', reset: '', pad_first: false) ⇒ 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