Sha256: a7e95bca48d5270871a693cf5bad33ee2f983080a5aff85cbbddb106a6c9cc83

Contents?: true

Size: 791 Bytes

Versions: 22

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  module StepsSerializers
    class HumanReadableBytecode < Bytecode
      def serialize
        steps = ShortcutsApplyer.call(@steps)
        [steps.configuration_steps, steps.steps].map do |stps|
          stps.map { |s| serialize_step(s) }
        end
      end

      private

      def serialize_arg(arg)
        return arg.to_s if arg.is_a?(TypedValue)
        return serialize_predicate(arg) if arg.is_a?(Expressions::P::Predicate)
        return arg.value if arg.is_a?(Expressions::WithOptions)

        return arg unless arg.is_a?(Steps)

        HumanReadableBytecode.new(arg, **@params.merge(no_return: false)).serialize[1]
      end

      def serialize_predicate(arg)
        "#{arg.name}(#{arg.value})"
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
grumlin-0.23.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.22.5 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.22.4 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.22.3 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.22.2 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.22.1 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.22.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.21.1 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.21.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.20.2 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.20.1 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.20.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.7 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.6 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.5 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.4 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.3 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.2 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.1 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-0.19.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb