Class: GuiGeo::Point
- Inherits:
-
Struct
- Object
- Struct
- GuiGeo::Point
- Includes:
- Tools
- Defined in:
- lib/gui_geometry/point.rb
Constant Summary
Constants included from GuiGeo
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #*(b) ⇒ Object
- #+(b) ⇒ Object
- #-(b) ⇒ Object
- #/(b) ⇒ Object
- #<(b) ⇒ Object
- #<=(b) ⇒ Object
- #>(b) ⇒ Object
- #>=(b) ⇒ Object
- #bound(a, b) ⇒ Object
- #clone ⇒ Object
- #clone_value(v) ⇒ Object
-
#initialize(*args) ⇒ Point
constructor
A new instance of Point.
- #inspect ⇒ Object
- #max(b) ⇒ Object
- #min(b) ⇒ Object
- #to_s ⇒ Object
Methods included from Tools
Methods included from GuiGeo
Constructor Details
#initialize(*args) ⇒ Point
Returns a new instance of Point.
5 6 7 8 |
# File 'lib/gui_geometry/point.rb', line 5 def initialize(*args) self.x = self.y = 0 super if args.length!=0 end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
2 3 4 |
# File 'lib/gui_geometry/point.rb', line 2 def x @x end |
#y ⇒ Object
Returns the value of attribute y
2 3 4 |
# File 'lib/gui_geometry/point.rb', line 2 def y @y end |
Instance Method Details
#*(b) ⇒ Object
33 |
# File 'lib/gui_geometry/point.rb', line 33 def *(b) b.kind_of?(Point) ? point(x*b.x, y*b.y) : point(x*b, y*b) end |
#+(b) ⇒ Object
31 |
# File 'lib/gui_geometry/point.rb', line 31 def +(b) b.kind_of?(Point) ? point(x+b.x, y+b.y) : point(x+b, y+b) end |
#-(b) ⇒ Object
32 |
# File 'lib/gui_geometry/point.rb', line 32 def -(b) b.kind_of?(Point) ? point(x-b.x, y-b.y) : point(x-b, y-b) end |
#/(b) ⇒ Object
34 |
# File 'lib/gui_geometry/point.rb', line 34 def /(b) b.kind_of?(Point) ? point(x/b.x, y/b.y) : point(x/b, y/b) end |
#<(b) ⇒ Object
29 |
# File 'lib/gui_geometry/point.rb', line 29 def <(b) x<b.x && y<b.y end |
#<=(b) ⇒ Object
27 |
# File 'lib/gui_geometry/point.rb', line 27 def <=(b) x<=b.x && y<=b.y end |
#>(b) ⇒ Object
28 |
# File 'lib/gui_geometry/point.rb', line 28 def >(b) x>b.x && y>b.y end |
#>=(b) ⇒ Object
26 |
# File 'lib/gui_geometry/point.rb', line 26 def >=(b) x>=b.x && y>=b.y end |
#bound(a, b) ⇒ Object
12 |
# File 'lib/gui_geometry/point.rb', line 12 def bound(a, b); point(Tools::bound(a.x, x, b.x), Tools::bound(a.y, y, b.y)); end |
#clone ⇒ Object
21 |
# File 'lib/gui_geometry/point.rb', line 21 def clone; point(clone_value(x), clone_value(y)); end |
#clone_value(v) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/gui_geometry/point.rb', line 14 def clone_value(v) case v when Fixnum, Bignum, Float then v else v.clone end end |
#inspect ⇒ Object
23 |
# File 'lib/gui_geometry/point.rb', line 23 def inspect; "point(#{x},#{y})" end |
#max(b) ⇒ Object
11 |
# File 'lib/gui_geometry/point.rb', line 11 def max(b); point(Tools::max(x, b.x), Tools::max(y, b.y)); end |
#min(b) ⇒ Object
10 |
# File 'lib/gui_geometry/point.rb', line 10 def min(b); point(Tools::min(x, b.x), Tools::min(y, b.y)); end |
#to_s ⇒ Object
24 |
# File 'lib/gui_geometry/point.rb', line 24 def to_s; "(#{x},#{y})" end |