Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/makitzo/monkeys/string.rb
Instance Method Summary collapse
- #indent(spaces) ⇒ Object
-
#last_line ⇒ Object
returns last non-empty line of string, or the empty string if none exists.
Instance Method Details
#indent(spaces) ⇒ Object
2 3 4 |
# File 'lib/makitzo/monkeys/string.rb', line 2 def indent(spaces) gsub(/^/, " " * spaces) end |
#last_line ⇒ Object
returns last non-empty line of string, or the empty string if none exists
7 8 9 10 11 12 13 14 |
# File 'lib/makitzo/monkeys/string.rb', line 7 def last_line lines = split("\n") while line = lines.pop line.strip! return line unless line.length == 0 end return '' end |