Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/dm-forms/core_ext.rb
Instance Method Summary collapse
-
#humanize ⇒ Object
Convert to a human readable string.
-
#indent(tabs = 1) ⇒ Object
Indent a string with pseudo
tabs(spaces).
Instance Method Details
#humanize ⇒ Object
Convert to a human readable string.
Examples:
'im_a_simple.String'.humanize # => 'im a simple String'
19 20 21 |
# File 'lib/dm-forms/core_ext.rb', line 19 def humanize gsub(/[^a-zA-Z\d]/, ' ') || self end |
#indent(tabs = 1) ⇒ Object
Indent a string with pseudo tabs (spaces). Defaults to a single tab.
26 27 28 |
# File 'lib/dm-forms/core_ext.rb', line 26 def indent tabs = 1 gsub /^/, ' ' * tabs end |