Sha256: b4e81ee2e99d1921618940c8fb40a4c40179ba849a75161d539ada91af9c0733
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Grumlin class AnonymousStep attr_reader :name, :args # TODO: add other steps SUPPORTED_STEPS = %w[E V addE addV as by coalesce count dedup drop elementMap emit fold from group groupCount has hasId hasLabel hasNot in inV label limit not order out outE path project property repeat select to unfold valueMap values where].freeze def initialize(name, *args, previous_steps: []) @name = name @previous_steps = previous_steps @args = args end SUPPORTED_STEPS.each do |step| define_method step do |*args| add_step(step, args, previous_steps: steps) end end def inspect @inspect ||= to_bytecode.to_s end alias to_s inspect def to_bytecode @to_bytecode ||= (@previous_steps.last&.to_bytecode || []) + [Translator.to_bytecode(self)] end def steps (@previous_steps + [self]) end private def add_step(step_name, args, previous_steps:) self.class.new(step_name, *args, previous_steps: previous_steps) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grumlin-0.7.0 | lib/grumlin/anonymous_step.rb |
grumlin-0.6.2 | lib/grumlin/anonymous_step.rb |