Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Instance Method Summary collapse
-
#comment ⇒ Object
Comments a line if it is not already commented out.
-
#commented? ⇒ Boolean
Checks if a line is commented out or not.
-
#strip_beginning ⇒ Object
Removes whitespace from the beginning of the String.
-
#uncomment ⇒ Object
Uncomments a line if it is commented out.
Instance Method Details
#comment ⇒ Object
Comments a line if it is not already commented out.
10 11 12 |
# File 'lib/core_ext/string.rb', line 10 def comment commented? ? self : "# #{self}" end |
#commented? ⇒ Boolean
Checks if a line is commented out or not.
5 6 7 |
# File 'lib/core_ext/string.rb', line 5 def commented? start_with?("#") end |
#strip_beginning ⇒ Object
Removes whitespace from the beginning of the String.
20 21 22 |
# File 'lib/core_ext/string.rb', line 20 def strip_beginning gsub(/^\s*/, "") end |
#uncomment ⇒ Object
Uncomments a line if it is commented out.
15 16 17 |
# File 'lib/core_ext/string.rb', line 15 def uncomment gsub(/^#\s*/, "") end |