Class: Point

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/rfuzzy/point.rb

Overview

Point used for adherence functions. Should not be thought of as a point-in-space.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Point

y must be [0;1]



10
11
12
13
14
15
16
# File 'lib/rfuzzy/point.rb', line 10

def initialize(x, y)
	@x = x.to_f
	if y < 0 || y > 1
		raise RangeError, "Function values for fuzzy sets must be from [0;1]", caller
	end
	@y = y.to_f
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/rfuzzy/point.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'lib/rfuzzy/point.rb', line 6

def y
  @y
end

Instance Method Details

#<=>(other) ⇒ Object

This is here only for sorting, should not be used for ‘real’ comparsion



28
29
30
# File 'lib/rfuzzy/point.rb', line 28

def <=>(other)
	@x <=> other.x
end

#to_gplotObject

Convenient for use with GNUplot.



23
24
25
# File 'lib/rfuzzy/point.rb', line 23

def to_gplot
	return "#{@x} #{@y}\n"
end

#to_sObject



18
19
20
# File 'lib/rfuzzy/point.rb', line 18

def to_s
	return "(#{@x},#{@y})"
end