Sha256: 27bf0ef3361e8ec0b667c385a69b7872830bf73d1e56cc9f86f2f912ce3575f3

Contents?: true

Size: 366 Bytes

Versions: 3

Compression:

Stored size: 366 Bytes

Contents

require 'facets/functor'

class String

  # TODO: Should String#linear be moved to separate functor gem?

  # Like `#newlines` but returns a Functor instead.
  #
  #   "a \n b \n c".linear.strip   #=> "a\nb\nc"
  #
  def linear
    Functor.new do |op, *a, &b|
      lines.map { |line|
        line.chomp.public_send(op, *a, &b)
      }.join("\n")
    end
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/string/linear.rb
facets-3.1.0 lib/core/facets/string/linear.rb
facets-3.0.0 lib/core/facets/string/linear.rb