Sha256: c8dedf909b5f458dc7e6dd3ce2cdacf7546dca3ef826bd4f0f2a5ce99f5c72e6

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Grumlin
  class AnonymousStep
    attr_reader :name, :args, :previous_step

    # TODO: add other steps
    SUPPORTED_STEPS = %i[E V addE addV as both by coalesce count dedup drop elementMap emit fold from group groupCount
                         has hasId hasLabel hasNot id in inE inV label limit not order out outE path project property
                         range repeat select skip tail to unfold union until valueMap values where with].freeze

    def initialize(name, *args, previous_step: nil)
      @name = name
      @previous_step = previous_step
      @args = args
    end

    SUPPORTED_STEPS.each do |step|
      define_method(step) do |*args|
        add_step(step, args)
      end
    end

    def inspect
      bytecode.inspect
    end

    alias to_s inspect

    def bytecode(no_return: false)
      @bytecode ||= Bytecode.new(self, no_return: no_return)
    end

    private

    def add_step(step_name, args)
      self.class.new(step_name, *args, previous_step: self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grumlin-0.12.1 lib/grumlin/anonymous_step.rb