class SqlPostgres::PgTwoPoints
This is the base class for data types which have two points
Attributes
p1[R]
Return the first endpoint
p2[R]
Return the second endpoint
Public Class Methods
new(*args)
click to toggle source
Constructor. Takes either 0 arguments, which sets both endpoints to (0, 0), or 2 PgPoint
arguments, or 4 float arguments.
# File lib/sqlpostgres/PgTwoPoints.rb, line 20 def initialize(*args) case args.size when 0 @p1 = PgPoint.new @p2 = PgPoint.new when 2 @p1 = args[0] @p2 = args[1] when 4 @p1 = PgPoint.new(*args[0..1]) @p2 = PgPoint.new(*args[2..3]) end end
Public Instance Methods
to_s()
click to toggle source
Return a string representation (ie “((1, 2), (3, 4))”).
# File lib/sqlpostgres/PgTwoPoints.rb, line 36 def to_s "(%s, %s)" % [p1, p2] end
Protected Instance Methods
parts()
click to toggle source
# File lib/sqlpostgres/PgTwoPoints.rb, line 42 def parts [p1, p2] end