class SqlPostgres::PgPath
This class holds the value of a “path” column.
Attributes
closed[R]
points[R]
Public Class Methods
from_sql(s)
click to toggle source
Create a PgPath
from a string in Postgres format
# File lib/sqlpostgres/PgPath.rb, line 16 def from_sql(s) if s =~ /^(\[)\(.*\)(,\(.*\))?\]$/ || s =~ /^(\()\(.*\)(,\(.*\))?\)$/ closed = $1 == "(" points = s.scan(/\([^(]*?\)/).collect do |t| PgPoint.from_sql(t) end PgPath.new(closed, *points) else raise ArgumentError, "Invalid path: #{s.inspect}" end end
new(closed = true, *points)
click to toggle source
# File lib/sqlpostgres/PgPath.rb, line 30 def initialize(closed = true, *points) @points = points @closed = closed end
Public Instance Methods
to_s()
click to toggle source
# File lib/sqlpostgres/PgPath.rb, line 35 def to_s s = points.join(", ") if closed "(#{s})" else "[#{s}]" end end
Protected Instance Methods
parts()
click to toggle source
# File lib/sqlpostgres/PgPath.rb, line 46 def parts [closed, points] end
Private Instance Methods
column_type()
click to toggle source
# File lib/sqlpostgres/PgPath.rb, line 52 def column_type 'path' end