Sha256: 08e12a4ea9b488ab0c6570e3cf3a9256c1161524e9e5e45fe7664aaaf38eebaf

Contents?: true

Size: 441 Bytes

Versions: 2

Compression:

Stored size: 441 Bytes

Contents

class String

  # Places a string to the right of the current string
  #
  # Example:
  #   ab        ef      abef
  #   cd .next( gh ) => cdgh
  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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubycards-0.0.2 lib/extensions/string.rb
rubycards-0.0.1 lib/extensions/string.rb