class Bmg::Operator::Unwrap

Attributes

attrs[R]

Public Class Methods

new(type, operand, attrs) click to toggle source
# File lib/bmg/operator/unwrap.rb, line 6
def initialize(type, operand, attrs)
  @type = type
  @operand = operand
  @attrs = attrs
end

Public Instance Methods

each() { |tuple_unwrap(tuple)| ... } click to toggle source
# File lib/bmg/operator/unwrap.rb, line 18
def each(&bl)
  return to_enum unless block_given?
  operand.each do |tuple|
    yield tuple_unwrap(tuple)
  end
end
to_ast() click to toggle source
# File lib/bmg/operator/unwrap.rb, line 25
def to_ast
  [ :unwrap, operand.to_ast, attrs ]
end

Protected Instance Methods

tuple_unwrap(tuple) click to toggle source
# File lib/bmg/operator/unwrap.rb, line 31
def tuple_unwrap(tuple)
  attrs.inject(tuple.dup){|t,attr|
    t.merge(tuple[attr]).tap{|t2|
      t2.delete(attr)
    }
  }
end