Sha256: 409f26a4aadcc07c356f2ad4964eddd67b44b97aa85c512c2d6e046bf57797fc

Contents?: true

Size: 928 Bytes

Versions: 7

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

require_relative 'designation'
require_relative 'any_value'
require_relative 'vocabulary'

module MiniKraken
  module Core
    # Representation of a MiniKraken variable.
    # It is a named slot that can be associated with one value.
    class Variable
      include Designation # Mixin: Acquire name attribute

      # @return [String] Internal variable name used by MiniKraken
      attr_accessor :i_name

      # @param aName [String] The name of the variable
      def initialize(aName)
        init_designation(aName)
        @i_name = name.dup
      end

      def fused?
        name != i_name
      end

      def quote(anEnvironment)
        raise StandardError, "class #{anEnvironment}" unless anEnvironment.kind_of?(Vocabulary)

        val = anEnvironment.quote_ref(self)
        val.nil? ? AnyValue.new(name, anEnvironment) : val
      end
    end # class
  end # module
end # module

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mini_kraken-0.1.12 lib/mini_kraken/core/variable.rb
mini_kraken-0.1.11 lib/mini_kraken/core/variable.rb
mini_kraken-0.1.10 lib/mini_kraken/core/variable.rb
mini_kraken-0.1.09 lib/mini_kraken/core/variable.rb
mini_kraken-0.1.08 lib/mini_kraken/core/variable.rb
mini_kraken-0.1.07 lib/mini_kraken/core/variable.rb
mini_kraken-0.1.06 lib/mini_kraken/core/variable.rb