Class: SqlPostgres::PgCircle
- Defined in:
- lib/sqlpostgres/PgCircle.rb
Overview
This class holds the value of a “circle” column.
Instance Attribute Summary collapse
-
#center ⇒ Object
readonly
Return the center (PgPoint).
-
#radius ⇒ Object
readonly
Return the radius.
Class Method Summary collapse
-
.from_sql(s) ⇒ Object
Create a PgCircle from a string in Postgres format.
Instance Method Summary collapse
-
#initialize(*args) ⇒ PgCircle
constructor
Constructor.
-
#to_s ⇒ Object
Return a string representation (ie “<(1, 2), 3>”).
Methods inherited from PgType
Constructor Details
#initialize(*args) ⇒ PgCircle
Constructor
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sqlpostgres/PgCircle.rb', line 33 def initialize(*args) case args.size when 0 @center = PgPoint.new @radius = 0 when 2 @center = args[0] @radius = args[1] when 3 @center = PgPoint.new(*args[0..1]) @radius = args[2] else raise ArgumentError, "Incorrect number of arguments: #{args.size}" end end |
Instance Attribute Details
#center ⇒ Object (readonly)
Return the center (PgPoint)
11 12 13 |
# File 'lib/sqlpostgres/PgCircle.rb', line 11 def center @center end |
#radius ⇒ Object (readonly)
Return the radius
15 16 17 |
# File 'lib/sqlpostgres/PgCircle.rb', line 15 def radius @radius end |
Class Method Details
Instance Method Details
#to_s ⇒ Object
Return a string representation (ie “<(1, 2), 3>”).
51 52 53 |
# File 'lib/sqlpostgres/PgCircle.rb', line 51 def to_s "<%s, %g>" % parts end |