Class: Torque::PostgreSQL::Line

Inherits:
Struct
  • Object
show all
Defined in:
lib/torque/postgresql/adapter/oid/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#interceptObject Also known as: c

Returns the value of attribute intercept

Returns:

  • (Object)

    the current value of intercept



3
4
5
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 3

def intercept
  @intercept
end

#slopeObject

Returns the value of attribute slope

Returns:

  • (Object)

    the current value of slope



3
4
5
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 3

def slope
  @slope
end

Instance Method Details

#aObject



13
14
15
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 13

def a
  slope.numerator
end

#a=(value) ⇒ Object



7
8
9
10
11
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 7

def a=(value)
  self.slope = vertical? \
    ? Float::INFINITY \
    : Rational(value, b)
end

#bObject



23
24
25
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 23

def b
  vertical? ? 0 : slope.denominator
end

#b=(value) ⇒ Object



17
18
19
20
21
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 17

def b=(value)
  self.slope = value.zero? \
    ? Float::INFINITY \
    : Rational(a, value)
end

#horizontal?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 27

def horizontal?
  slope.zero?
end

#vertical?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 31

def vertical?
  !slope.try(:infinite?).eql?(nil)
end