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



5
6
7
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 5

def intercept
  @intercept
end

#slopeObject

Returns the value of attribute slope

Returns:

  • (Object)

    the current value of slope



5
6
7
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 5

def slope
  @slope
end

Instance Method Details

#aObject



15
16
17
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 15

def a
  slope.numerator
end

#a=(value) ⇒ Object



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

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

#bObject



25
26
27
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 25

def b
  vertical? ? 0 : slope.denominator
end

#b=(value) ⇒ Object



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

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

#horizontal?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 29

def horizontal?
  slope.zero?
end

#vertical?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/torque/postgresql/adapter/oid/line.rb', line 33

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