Sha256: dec86ee885ccfb8de1cc932c570c6120b7137399d84c52499fc2402628cf1dfe
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Grumlin module Translator class << self def to_bytecode(steps) return arg_to_bytecode(steps) if steps.is_a?(AnonymousStep) steps.map do |step| arg_to_bytecode(step) end end def to_bytecode_query(steps) steps.map do |step| arg_to_query_bytecode(step) end end private def arg_to_bytecode(arg) return arg.to_bytecode if arg.is_a?(TypedValue) return arg unless arg.is_a?(AnonymousStep) args = arg.args.flatten.map do |a| a.instance_of?(AnonymousStep) ? to_bytecode(a.steps) : arg_to_bytecode(a) end [arg.name, *args] end def arg_to_query_bytecode(arg) return ["none"] if arg.nil? return arg.to_bytecode if arg.is_a?(TypedValue) return arg unless arg.is_a?(AnonymousStep) # return arg.to_bytecode if arg.is_a?(TypedValue) args = arg.args.flatten.map do |a| a.instance_of?(AnonymousStep) ? Typing.to_bytecode(to_bytecode(a.steps)) : arg_to_query_bytecode(a) end [arg.name, *args] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
grumlin-0.7.0 | lib/grumlin/translator.rb |
grumlin-0.6.2 | lib/grumlin/translator.rb |
grumlin-0.6.1 | lib/grumlin/translator.rb |
grumlin-0.6.0 | lib/grumlin/translator.rb |