Sha256: 54c13296b6c6ae2f69e7ea5b518becd160a31edfd061589e37edaea1614f616f
Contents?: true
Size: 618 Bytes
Versions: 4
Compression:
Stored size: 618 Bytes
Contents
# frozen_string_literal: true module Pipeable module Steps # Inserts elements before, after, or around input. class Insert < Abstract LAST = -1 def initialize(*positionals, at: LAST, **) super(*positionals, **) @value = positionals.empty? ? base_keywords : positionals.flatten @at = at end def call result result.fmap do |input| cast = input.is_a?(Array) ? input : [input] value.is_a?(Array) ? cast.insert(at, *value) : cast.insert(at, value) end end private attr_reader :value, :at end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pipeable-0.4.0 | lib/pipeable/steps/insert.rb |
pipeable-0.3.0 | lib/pipeable/steps/insert.rb |
pipeable-0.2.0 | lib/pipeable/steps/insert.rb |
pipeable-0.1.0 | lib/pipeable/steps/insert.rb |