Sha256: 3212782c9c774a5859435e66e3f3beb0d53e6625fa4e1a63fff33501afbebd25

Contents?: true

Size: 1.32 KB

Versions: 13

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module MiniKraken
  module Core
    # Wordnet definition: Identifying word or words by which someone or
    # something is called and classified or distinguished from others.
    # Mix-in module that contains factored code for managing named entries
    # in a vocabulary such as variables and variable references.
    module Designation
      # @return [String] User-defined name of the variable
      attr_reader :name

      def init_designation(aName)
        @name = valid_name(aName)
      end

      # @param voc [Vocabulary]
      # @return [Freshness]
      def freshness(voc)
        voc.freshness_ref(self)
      end

      # @param voc [Vocabulary]
      # @return [Boolean]
      def fresh?(voc)
        frsh = freshness(voc)
        frsh.degree == :fresh || frsh.degree == :bound
      end

      # @param voc [Vocabulary]
      # @return [Boolean]
      def bound?(voc)
        frsh = freshness(voc)
        frsh.degree == :bound
      end

      # @param voc [Vocabulary]
      # @return [Boolean]
      def ground?(voc)
        frsh = freshness(voc)
        frsh.degree == :bound
      end

      private

      def valid_name(aName)
        if aName.empty?
          raise StandardError, 'Variable name may not be empty.'
        end

        aName
      end
    end # class
  end # module
end # module

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mini_kraken-0.2.04 lib/mini_kraken/core/designation.rb
mini_kraken-0.2.03 lib/mini_kraken/core/designation.rb
mini_kraken-0.2.02 lib/mini_kraken/core/designation.rb
mini_kraken-0.2.01 lib/mini_kraken/core/designation.rb
mini_kraken-0.2.00 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.13 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.12 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.11 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.10 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.09 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.08 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.07 lib/mini_kraken/core/designation.rb
mini_kraken-0.1.06 lib/mini_kraken/core/designation.rb