Sha256: c9aded8110d4df8610bd753e2c56c28082a7515b23a5740305459def835c627a

Contents?: true

Size: 925 Bytes

Versions: 1

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

module Tataru
  # Reads Rom values
  module RomReader
    def rom
      memory.hash[:rom]
    end

    def resolve(object)
      case object[:type]
      when :literal
        object[:value]
      when :hash
        resolve_hash(object)
      when :array
        resolve_array(object)
      when :output
        resolve_output(object)
      end
    end

    def resolve_array(object)
      result = []
      object[:references].each do |k, v|
        result[k] = resolve(rom[v])
      end
      result
    end

    def resolve_hash(object)
      result = {}
      object[:references].each do |k, v|
        result[k] = resolve(rom[v])
      end
      result
    end

    def resolve_output(object)
      if object[:output] == :remote_id
        memory.hash[:remote_ids][object[:resource]]
      else
        memory.hash[:outputs][object[:resource]][object[:output]]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tataru-0.2.0 lib/tataru/rom_reader.rb