Sha256: f4c81a5b932a0ef266f9c6ab66ab5bef8ba29fdc0ca90b00cef3b27177cd9a0a

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

module Nocode
  # Describes the environment for each running step.  An instance is initialized when a job
  # kicks off and then is passed from step to step.
  class Context
    attr_reader :io, :parameters, :registers

    def initialize(io: $stdout, parameters: {}, registers: {})
      @io         = io || $stdout
      @parameters = Util::Dictionary.ensure(parameters)
      @registers  = Util::Dictionary.ensure(registers)

      freeze
    end

    def register(key)
      registers[key]
    end

    def parameter(key)
      parameters[key]
    end

    def to_h
      {
        'registers' => registers,
        'parameters' => parameters
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nocode-0.0.5 lib/nocode/context.rb
nocode-0.0.4 lib/nocode/context.rb