Class: SqlPostgres::PgPoint
Overview
This class holds the value of a “point” column.
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Return the x coordinate.
-
#y ⇒ Object
readonly
Return the y coordinate.
Class Method Summary collapse
-
.from_sql(s) ⇒ Object
Create a PgPoint from a string in Postgres format (ie “(1,2)”).
Instance Method Summary collapse
-
#initialize(x = 0, y = 0) ⇒ PgPoint
constructor
Constructor taking the x and y coordinate.
-
#to_s ⇒ Object
Return a string representation (ie “(1, 2)”).
Methods inherited from PgType
Constructor Details
#initialize(x = 0, y = 0) ⇒ PgPoint
Constructor taking the x and y coordinate
34 35 36 37 |
# File 'lib/sqlpostgres/PgPoint.rb', line 34 def initialize(x = 0, y = 0) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Return the x coordinate
11 12 13 |
# File 'lib/sqlpostgres/PgPoint.rb', line 11 def x @x end |
#y ⇒ Object (readonly)
Return the y coordinate
15 16 17 |
# File 'lib/sqlpostgres/PgPoint.rb', line 15 def y @y end |
Class Method Details
Instance Method Details
#to_s ⇒ Object
Return a string representation (ie “(1, 2)”).
41 42 43 |
# File 'lib/sqlpostgres/PgPoint.rb', line 41 def to_s "(%g, %g)" % parts end |