Sha256: b9c62b87ba0e2c29cb906fb7b9a9c07a04957a155201e4fd989df2a3618512d7

Contents?: true

Size: 790 Bytes

Versions: 15

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

class Grumlin::StepsSerializers::HumanReadableBytecode < Grumlin::StepsSerializers::Bytecode
  def serialize
    steps = Grumlin::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?(Grumlin::TypedValue)
    return serialize_predicate(arg) if arg.is_a?(Grumlin::Expressions::P::Predicate)
    return arg.value if arg.is_a?(Grumlin::Expressions::WithOptions)

    return arg unless arg.is_a?(Grumlin::Steps)

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
grumlin-1.2.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.1.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.4 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.3 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.3.beta1 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.2 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.1 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0.rc7 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0.rc6 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0.rc5 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0.rc4 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0.rc3 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0.rc2 lib/grumlin/steps_serializers/human_readable_bytecode.rb
grumlin-1.0.0.rc1 lib/grumlin/steps_serializers/human_readable_bytecode.rb