Class: SqlPostgres::PgBox

Inherits:
PgTwoPoints show all
Defined in:
lib/sqlpostgres/PgBox.rb

Overview

This class holds the value of a “point” column.

Instance Attribute Summary

Attributes inherited from PgTwoPoints

#p1, #p2

Class Method Summary collapse

Methods inherited from PgTwoPoints

#initialize, #to_s

Methods inherited from PgType

#eql?, #hash, #to_sql

Constructor Details

This class inherits a constructor from SqlPostgres::PgTwoPoints

Class Method Details

.from_sql(s) ⇒ Object

Create a PgBox from a string in Postgres format



13
14
15
16
17
18
19
# File 'lib/sqlpostgres/PgBox.rb', line 13

def from_sql(s)
  if s =~ /^(\(.*\)),(\(.*\))$/
    PgBox.new(PgPoint.from_sql($1), PgPoint.from_sql($2))
  else
    raise ArgumentError, "Invalid box: #{s.inspect}"
  end
end