Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#commentObject

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.

Returns:

  • (Boolean)


5
6
7
# File 'lib/core_ext/string.rb', line 5

def commented?
  start_with?("#")
end

#strip_beginningObject

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

#uncommentObject

Uncomments a line if it is commented out.



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

def uncomment
  gsub(/^#\s*/, "")
end