Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/extensions/string.rb
Instance Method Summary collapse
-
#next(str) ⇒ String
Places a string to the right of the current string.
Instance Method Details
#next(str) ⇒ String
Places a string to the right of the current string
Example:
ab ef abef
cd .next( gh ) => cdgh
10 11 12 13 14 15 16 17 |
# File 'lib/extensions/string.rb', line 10 def next(str) # zip the two strings, split by line breaks zipped = self.split("\n").zip(str.split("\n")) # map the zipped strings, by joining each pair and ending # with a new line, then joining the whole thing together zipped.map { |e| "#{e.join}" }.join "\n" end |