Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/fedux_org_stdlib/core_ext/string/underline.rb,
lib/fedux_org_stdlib/core_ext/string.rb,
lib/fedux_org_stdlib/core_ext/string/characterize.rb

Overview

String

Instance Method Summary collapse

Instance Method Details

#characterizeObject

Convert string to characters only

This will remove accents and umlauts and other special characters

‘ä’.characterize #=> ‘a’

Examples:

Simple Example



15
16
17
# File 'lib/fedux_org_stdlib/core_ext/string/characterize.rb', line 15

def characterize
  ActiveSupport::Inflector.transliterate(self).parameterize
end

#underline(character: '-') ⇒ String

Underline a string

Parameters:

  • character (String) (defaults to: '-')

    (‘-’) The character used to underline the string

Returns:

  • (String)

    The string + underline



11
12
13
14
15
16
17
# File 'lib/fedux_org_stdlib/core_ext/string/underline.rb', line 11

def underline(character: '-')
  result = []
  result << self
  result << gsub(/./, character)

  result.join("\n")
end