Class Index [+]

Quicksearch

Sequel::Postgres::PGNumericArray

PGArray subclass handling integer and float types, using a fast JSON parser. Does not handle numeric/decimal types, since JSON does deal with arbitrary precision (see PGDecimalArray for that).

Constants

SUBST

Character conversion map mapping input strings to JSON replacements

SUBST_RE

Regular expression matching input strings to convert

Public Class Methods

parse(string, type=nil) click to toggle source

Parse the input string by using a gsub to convert non-JSON characters to JSON, running it through a regular JSON parser, and the doing a recursive map over the output to make sure the entries are in the correct type (mostly, to make sure real/double precision database types are returned as float and not integer).

     # File lib/sequel/extensions/pg_array.rb, line 349
349:       def self.parse(string, type=nil)
350:         new(recursive_map(JSON.parse(string.gsub(SUBST_RE){|m| SUBST[m]})), type)
351:       end

Private Class Methods

recursive_map(array) click to toggle source

Convert each item in the array to the correct type, handling multi-dimensional arrays.

     # File lib/sequel/extensions/pg_array.rb, line 355
355:       def self.recursive_map(array)
356:         array.map do |i|
357:           if i.is_a?(Array)
358:             recursive_map(i)
359:           elsif i
360:             convert_item(i)
361:           end
362:         end
363:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.