Sha256: 7ddcc27c5de422dcc522018fce93c142413cb1ff775723045f85e07463ebd2a9

Contents?: true

Size: 779 Bytes

Versions: 5

Compression:

Stored size: 779 Bytes

Contents

module Alf
  module Algebra
    module Visitor

      def copy_and_apply(expr)
        if expr.is_a?(Algebra::Operator)
          expr.with_operands(*expr.operands.map{|op| apply(op) })
        else
          expr
        end
      end

    private

      def to_method_name(expr, prefix = "on_")
        case expr
        when Algebra::Operator
          name = expr.class.rubycase_name
          meth = :"#{prefix}#{name}"
          meth = :"#{prefix}shortcut" if expr.is_a?(Algebra::Shortcut) and !respond_to?(meth)
          meth = :"#{prefix}missing" unless respond_to?(meth)
          meth
        when Algebra::Operand
          :on_leaf_operand
        else
          :not_supported
        end
      end

    end # module Visitor
  end # module Algebra
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/algebra/support/visitor.rb
alf-core-0.16.2 lib/alf/algebra/support/visitor.rb
alf-core-0.16.1 lib/alf/algebra/support/visitor.rb
alf-core-0.16.0 lib/alf/algebra/support/visitor.rb
alf-core-0.15.0 lib/alf/algebra/support/visitor.rb