Sha256: 65d7c95122fc6ba6368f4a2fca4a8fc2e47710c3f90250d178bf67aa47df953e

Contents?: true

Size: 560 Bytes

Versions: 2

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

module Nocode
  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.3 lib/nocode/context.rb
nocode-0.0.2 lib/nocode/context.rb