Sha256: e753eebd772add033cf23054d9d06c8623a3a5086d93066cff75ecf7e7664a4a

Contents?: true

Size: 802 Bytes

Versions: 28

Compression:

Stored size: 802 Bytes

Contents

module Bmg
  module Operator
    class Unwrap
      include Operator::Unary

      def initialize(type, operand, attrs)
        @type = type
        @operand = operand
        @attrs = attrs
      end

    protected

      attr_reader :attrs

    public

      def each(&bl)
        return to_enum unless block_given?
        operand.each do |tuple|
          yield tuple_unwrap(tuple)
        end
      end

      def to_ast
        [ :unwrap, operand.to_ast, attrs ]
      end

    protected

      def tuple_unwrap(tuple)
        attrs.inject(tuple.dup){|t,attr|
          t.merge(tuple[attr]).tap{|t2|
            t2.delete(attr)
          }
        }
      end

    protected ### inspect

      def args
        [ attrs ]
      end

    end # class Unwrap
  end # module Operator
end # module Bmg

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/operator/unwrap.rb
bmg-0.23.2 lib/bmg/operator/unwrap.rb
bmg-0.23.1 lib/bmg/operator/unwrap.rb
bmg-0.23.0 lib/bmg/operator/unwrap.rb
bmg-0.21.5 lib/bmg/operator/unwrap.rb
bmg-0.21.4 lib/bmg/operator/unwrap.rb
bmg-0.20.5 lib/bmg/operator/unwrap.rb
bmg-0.19.3 lib/bmg/operator/unwrap.rb
bmg-0.21.3 lib/bmg/operator/unwrap.rb
bmg-0.21.2 lib/bmg/operator/unwrap.rb
bmg-0.21.0 lib/bmg/operator/unwrap.rb
bmg-0.20.4 lib/bmg/operator/unwrap.rb
bmg-0.20.2 lib/bmg/operator/unwrap.rb
bmg-0.20.1 lib/bmg/operator/unwrap.rb
bmg-0.20.0 lib/bmg/operator/unwrap.rb
bmg-0.19.2 lib/bmg/operator/unwrap.rb
bmg-0.19.1 lib/bmg/operator/unwrap.rb
bmg-0.19.0 lib/bmg/operator/unwrap.rb
bmg-0.18.15 lib/bmg/operator/unwrap.rb
bmg-0.18.14 lib/bmg/operator/unwrap.rb