Sha256: feddf82636e411609fd9c4c0e40a28a00c4451f15cf55301eb071b093d6e82e1

Contents?: true

Size: 875 Bytes

Versions: 5

Compression:

Stored size: 875 Bytes

Contents

module Alf
  module Engine
    #
    # Wraps attributes under as a sub-tuple
    #
    class Wrap < Cog

      # @return [Enumerable] The operand
      attr_reader :operand

      # @return [AttrList] Attributes to wrap
      attr_reader :attributes

      # @return [AttrName] Name of the introduced wrapped attribute
      attr_reader :as

      # @return [Boolean] Allbut wrapping?
      attr_reader :allbut

      # Creates a SetAttr instance
      def initialize(operand, attributes, as, allbut)
        @operand = operand
        @attributes = attributes
        @as = as
        @allbut = allbut
      end

      # (see Cog#each)
      def each
        operand.each do |tuple|
          rest, key = @attributes.split_tuple(tuple, @allbut)
          key[@as] = rest
          yield key
        end
      end

    end # class Wrap
  end # module Engine
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf-engine/alf/engine/wrap.rb
alf-0.12.1 lib/alf-engine/alf/engine/wrap.rb
alf-0.12.0 lib/alf-engine/alf/engine/wrap.rb
alf-0.11.1 lib/alf-engine/alf/engine/wrap.rb
alf-0.11.0 lib/alf-engine/alf/engine/wrap.rb