Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/extensions/string.rb
Instance Method Summary collapse
-
#next(str) ⇒ Object
Places a string to the right of the current string.
Instance Method Details
#next(str) ⇒ Object
Places a string to the right of the current string
Example:
ab ef abef
cd .next( gh ) => cdgh
8 9 10 11 12 13 14 15 |
# File 'lib/extensions/string.rb', line 8 def next(str) # zip the two strings, split by line breaks zipped = self.split("\n").zip(str.split("\n")).map # 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}\n" }.join end |