Class: FuzzyDomain

Inherits:
Object
  • Object
show all
Defined in:
lib/rfuzzy/fuzzy_domain.rb

Overview

Class for defining fuzzy domains.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*functions, &block) ⇒ FuzzyDomain

Constructor.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rfuzzy/fuzzy_domain.rb', line 6

def initialize(*functions, &block)
	@adherence_functions = {}
	functions.each do |f|
		unless @adherence_functions.has_key?(f.name)
			@adherence_functions[f.name] = function
		else
			raise ArgumentError, "Lexical variable '#{f.name}' already describes this FuzzyVar!"
		end	
	end
	if block_given?
		yield self
	end
end

Instance Attribute Details

#adherence_functionsObject (readonly)

Returns the value of attribute adherence_functions.



3
4
5
# File 'lib/rfuzzy/fuzzy_domain.rb', line 3

def adherence_functions
  @adherence_functions
end

Instance Method Details

#is_described_by(function, &block) ⇒ Object

Allows adding adherence functions with lexical variables describing the domain



21
22
23
24
25
26
27
28
29
30
# File 'lib/rfuzzy/fuzzy_domain.rb', line 21

def is_described_by(function, &block)
	if block_given?
		yield function
	end
	unless @adherence_functions.has_key?(function.name)
		@adherence_functions[function.name] = function
	else
		raise ArgumentError, "Lexical variable '#{function.name}' already describes this FuzzyVar!"
	end
end

#is_not_described_by(name) ⇒ Object

Removes adherence functions and lexical variables



33
34
35
# File 'lib/rfuzzy/fuzzy_domain.rb', line 33

def is_not_described_by(name)
	@adherence_functions.delete(name)
end