Class: String
- Inherits:
-
Object
- Object
- String
- 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,
lib/fedux_org_stdlib/core_ext/string/transliterate.rb
Overview
String
Instance Method Summary collapse
-
#characterize ⇒ Object
Convert string to characters only.
-
#transliterate ⇒ Object
Make umlauts less special.
-
#underline(character: '-') ⇒ String
Underline a string.
Instance Method Details
#characterize ⇒ Object
Convert string to characters only
This will remove accents and umlauts and other special characters
‘Donald E. Knütz’.characterize #=> ‘donald-e-knuth’
14 15 16 |
# File 'lib/fedux_org_stdlib/core_ext/string/characterize.rb', line 14 def characterize transliterate.parameterize end |
#transliterate ⇒ Object
Make umlauts less special
This will remove accents and umlauts and other specialities from characters.
ä => a á => a
‘Donald E. Knütz’.transliterate #=> ‘Donald E. Knutz’
19 20 21 |
# File 'lib/fedux_org_stdlib/core_ext/string/transliterate.rb', line 19 def transliterate ActiveSupport::Inflector.transliterate(self) end |
#underline(character: '-') ⇒ String
Underline a string
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 |