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
(also: #w, #width, #col, #column)
Returns the value of attribute x.
-
#y ⇒ Object
(also: #h, #height, #line)
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
- #area ⇒ Object
- #bound(a, b) ⇒ Object
- #clone ⇒ 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 Also known as: w, width, col, column
Returns the value of attribute x
2 3 4 |
# File 'lib/gui_geometry/point.rb', line 2 def x @x end |
#y ⇒ Object Also known as: h, height, line
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
35 |
# File 'lib/gui_geometry/point.rb', line 35 def *(b) b.kind_of?(Point) ? point(x*b.x, y*b.y) : point(x*b, y*b) end |
#+(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
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
36 |
# File 'lib/gui_geometry/point.rb', line 36 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) x<b.x && y<b.y end |
#<=(b) ⇒ Object
29 |
# File 'lib/gui_geometry/point.rb', line 29 def <=(b) x<=b.x && y<=b.y end |
#>(b) ⇒ Object
30 |
# File 'lib/gui_geometry/point.rb', line 30 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 |
#area ⇒ Object
38 |
# File 'lib/gui_geometry/point.rb', line 38 def area; x*y; end |
#bound(a, b) ⇒ Object
21 |
# File 'lib/gui_geometry/point.rb', line 21 def bound(a, b); point(Tools::bound(a.x, x, b.x), Tools::bound(a.y, y, b.y)); end |
#clone ⇒ Object
23 |
# File 'lib/gui_geometry/point.rb', line 23 def clone; point(clone_value(x), clone_value(y)); end |
#inspect ⇒ Object
25 |
# File 'lib/gui_geometry/point.rb', line 25 def inspect; "point(#{x},#{y})" end |
#max(b) ⇒ Object
20 |
# File 'lib/gui_geometry/point.rb', line 20 def max(b); point(Tools::max(x, b.x), Tools::max(y, b.y)); end |
#min(b) ⇒ Object
19 |
# File 'lib/gui_geometry/point.rb', line 19 def min(b); point(Tools::min(x, b.x), Tools::min(y, b.y)); end |
#to_s ⇒ Object
26 |
# File 'lib/gui_geometry/point.rb', line 26 def to_s; "(#{x},#{y})" end |