Class: Point
Overview
Point used for adherence functions. Should not be thought of as a point-in-space.
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
This is here only for sorting, should not be used for ‘real’ comparsion.
-
#initialize(x, y) ⇒ Point
constructor
y must be [0;1].
-
#to_gplot ⇒ Object
Convenient for use with GNUplot.
- #to_s ⇒ Object
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
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/rfuzzy/point.rb', line 6 def x @x end |
#y ⇒ Object
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_gplot ⇒ Object
Convenient for use with GNUplot.
23 24 25 |
# File 'lib/rfuzzy/point.rb', line 23 def to_gplot return "#{@x} #{@y}\n" end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/rfuzzy/point.rb', line 18 def to_s return "(#{@x},#{@y})" end |