Sha256: 700fe3a8ef6ba54027f9150e4e94b68d7f4910e6ba05ff2da328749a8587e8df

Contents?: true

Size: 1.93 KB

Versions: 9

Compression:

Stored size: 1.93 KB

Contents

module Bmg
  module Operator
    include Relation

    attr_reader :type
    attr_writer :type
    protected   :type=

    def to_s
      str = "(#{self.class.name.split('::').last.downcase}\n"
      str << operands.map{|op| op.to_s.gsub(/^/m, "  ") }.join("\n")
      str << "\n"
      str << args.map{|a| a.to_s.gsub(/^/m, "  ") }.join("\n")
      str << ")"
      str
    end

    def inspect
      str = "(#{self.class.name.split('::').last.downcase}\n"
      str << operands.map{|op| op.inspect.gsub(/^/m, "  ") }.join("\n")
      str << "\n"
      str << args.map{|a| a.inspect.gsub(/^/m, "  ") }.join("\n")
      str << ")"
      str
    end

    module Unary
      include Operator

      attr_reader :operand

      def _visit(parent, visitor)
        visitor.call(self, parent)
        operand._visit(self, visitor)
      end

      def operands
        [operand]
      end

    end

    module Binary
      include Operator

      attr_reader :left, :right

      def _visit(parent, visitor)
        visitor.call(self, parent)
        left._visit(self, visitor)
        right._visit(self, visitor)
      end

      def operands
        [left, right]
      end
    end

    module Nary
      include Operator

      attr_reader :operands

      def _visit(parent, visitor)
        visitor.call(self, parent)
        operands.each{|op| op._visit(self, visitor) }
      end
    end

  end
end
require_relative 'operator/allbut'
require_relative 'operator/autosummarize'
require_relative 'operator/autowrap'
require_relative 'operator/constants'
require_relative 'operator/extend'
require_relative 'operator/group'
require_relative 'operator/image'
require_relative 'operator/join'
require_relative 'operator/matching'
require_relative 'operator/not_matching'
require_relative 'operator/page'
require_relative 'operator/project'
require_relative 'operator/rename'
require_relative 'operator/restrict'
require_relative 'operator/rxmatch'
require_relative 'operator/union'

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bmg-0.16.0.pre.rc1 lib/bmg/operator.rb
bmg-0.15.0 lib/bmg/operator.rb
bmg-0.14.6 lib/bmg/operator.rb
bmg-0.14.5 lib/bmg/operator.rb
bmg-0.14.4 lib/bmg/operator.rb
bmg-0.14.3 lib/bmg/operator.rb
bmg-0.14.2 lib/bmg/operator.rb
bmg-0.14.1 lib/bmg/operator.rb
bmg-0.14.0 lib/bmg/operator.rb