Sha256: 0f9569a5bfcf098ed66890e2ffffe9c044d1bae1837e60d8f7a276bcf6370ffc

Contents?: true

Size: 632 Bytes

Versions: 3

Compression:

Stored size: 632 Bytes

Contents

require 'sqlpostgres/PgTwoPoints'

module SqlPostgres

  # This class holds the value of a "line segment" column.

  class PgLineSegment < PgTwoPoints

    class << self

      # Create a PgLineSegment from a string in Postgres format

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

    end

    private

    def column_type
      'lseg'
    end

  end

end

# Local Variables:
# tab-width: 2
# ruby-indent-level: 2
# indent-tabs-mode: nil
# End:

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sqlpostgres-1.2.6 lib/sqlpostgres/PgLineSegment.rb
sqlpostgres-1.2.5 lib/sqlpostgres/PgLineSegment.rb
sqlpostgres-1.2.4 lib/sqlpostgres/PgLineSegment.rb