Class: Geometer::Line

Inherits:
Struct
  • Object
show all
Defined in:
lib/geometer/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aObject

Returns the value of attribute a

Returns:

  • (Object)

    the current value of a



2
3
4
# File 'lib/geometer/line.rb', line 2

def a
  @a
end

#bObject

Returns the value of attribute b

Returns:

  • (Object)

    the current value of b



2
3
4
# File 'lib/geometer/line.rb', line 2

def b
  @b
end

Instance Method Details

#lengthObject



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