Class: PG::TextDecoder::Date
- Inherits:
-
SimpleDecoder
- Object
- Coder
- SimpleCoder
- SimpleDecoder
- PG::TextDecoder::Date
- Defined in:
- lib/pg/text_decoder.rb
Constant Summary collapse
- ISO_DATE =
/\A(\d{4})-(\d\d)-(\d\d)\z/
Constants inherited from Coder
Coder::FORMAT_ERROR_MASK, Coder::FORMAT_ERROR_TO_PARTIAL, Coder::FORMAT_ERROR_TO_RAISE, Coder::FORMAT_ERROR_TO_STRING, Coder::TIMESTAMP_APP_LOCAL, Coder::TIMESTAMP_APP_UTC, Coder::TIMESTAMP_DB_LOCAL, Coder::TIMESTAMP_DB_UTC
Instance Attribute Summary
Attributes inherited from Coder
Instance Method Summary collapse
Methods inherited from Coder
#==, #dup, #encode, #flags, #flags=, #format, #format=, #initialize, #inspect, #marshal_dump, #marshal_load, #oid, #oid=, #to_h
Constructor Details
This class inherits a constructor from PG::Coder
Instance Method Details
#decode(string, tuple = nil, field = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/pg/text_decoder.rb', line 11 def decode(string, tuple=nil, field=nil) if string =~ ISO_DATE ::Date.new $1.to_i, $2.to_i, $3.to_i else string end end |