Class: RDO::Postgres::Array::Float

Inherits:
RDO::Postgres::Array show all
Defined in:
lib/rdo/postgres/array/float.rb

Overview

Ruby handling for float[] type in PostgreSQL.

Instance Method Summary collapse

Methods inherited from RDO::Postgres::Array

[], #initialize, parse, #to_a, #to_s

Constructor Details

This class inherits a constructor from RDO::Postgres::Array

Instance Method Details

#format_value(v) ⇒ Object



25
26
27
# File 'lib/rdo/postgres/array/float.rb', line 25

def format_value(v)
  v.to_s
end

#parse_value(s) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rdo/postgres/array/float.rb', line 12

def parse_value(s)
  case s
  when "Infinity"
    ::Float::INFINITY
  when "-Infinity"
    -::Float::INFINITY
  when "NaN"
    ::Float::NAN
  else
    s.to_f
  end
end