Sha256: bbc4688c866268582587ea718aeab4c43cd83f23986fc6f6a24aa4d7e8459c42

Contents?: true

Size: 978 Bytes

Versions: 5

Compression:

Stored size: 978 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(env)
        raise StandardError, "class #{env}" unless env.kind_of?(Vocabulary)

        val = env.quote_ref(self)
        unless val
          result = AnyValue.new(name, env, env.names_fused(name))
        else
          result = val
        end

        result
      end
    end # class
  end # module
end # module

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mini_kraken-0.2.03 lib/mini_kraken/core/variable.rb
mini_kraken-0.2.02 lib/mini_kraken/core/variable.rb
mini_kraken-0.2.01 lib/mini_kraken/core/variable.rb
mini_kraken-0.2.00 lib/mini_kraken/core/variable.rb
mini_kraken-0.1.13 lib/mini_kraken/core/variable.rb