Class: SqlPostgres::PgTwoPoints
- Defined in:
- lib/sqlpostgres/PgTwoPoints.rb
Overview
This is the base class for data types which have two points
Direct Known Subclasses
Instance Attribute Summary collapse
-
#p1 ⇒ Object
readonly
Return the first endpoint.
-
#p2 ⇒ Object
readonly
Return the second endpoint.
Instance Method Summary collapse
-
#initialize(*args) ⇒ PgTwoPoints
constructor
Constructor.
-
#to_s ⇒ Object
Return a string representation (ie “((1, 2), (3, 4))”).
Methods inherited from PgType
Constructor Details
#initialize(*args) ⇒ PgTwoPoints
Constructor. Takes either 0 arguments, which sets both endpoints to (0, 0), or 2 PgPoint arguments, or 4 float arguments.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |
Instance Attribute Details
#p1 ⇒ Object (readonly)
Return the first endpoint
11 12 13 |
# File 'lib/sqlpostgres/PgTwoPoints.rb', line 11 def p1 @p1 end |
#p2 ⇒ Object (readonly)
Return the second endpoint
15 16 17 |
# File 'lib/sqlpostgres/PgTwoPoints.rb', line 15 def p2 @p2 end |
Instance Method Details
#to_s ⇒ Object
Return a string representation (ie “((1, 2), (3, 4))”).
36 37 38 |
# File 'lib/sqlpostgres/PgTwoPoints.rb', line 36 def to_s "(%s, %s)" % [p1, p2] end |