Class: Geometer::Line
- Inherits:
-
Struct
- Object
- Struct
- Geometer::Line
- Defined in:
- lib/geometer/line.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
Instance Method Summary collapse
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a
2 3 4 |
# File 'lib/geometer/line.rb', line 2 def a @a end |
#b ⇒ Object
Returns the value of attribute b
2 3 4 |
# File 'lib/geometer/line.rb', line 2 def b @b end |
Instance Method Details
#length ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/geometer/line.rb', line 3 def length x0,y0 = *a x1,y1 = *b dx = ((x0 - x1) ** 2) dy = ((y0 - y1) ** 2) Math.sqrt( dx + dy ) end |