Class: Perpetuity::Postgres::DateValue

Inherits:
Object
  • Object
show all
Defined in:
lib/perpetuity/postgres/date_value.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date) ⇒ DateValue

Returns a new instance of DateValue.



8
9
10
# File 'lib/perpetuity/postgres/date_value.rb', line 8

def initialize date
  @date = date
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



6
7
8
# File 'lib/perpetuity/postgres/date_value.rb', line 6

def date
  @date
end

Class Method Details

.from_sql(date_string) ⇒ Object



12
13
14
# File 'lib/perpetuity/postgres/date_value.rb', line 12

def self.from_sql date_string
  new(Date.parse(date_string))
end

Instance Method Details

#to_dateObject



16
17
18
# File 'lib/perpetuity/postgres/date_value.rb', line 16

def to_date
  date
end

#to_sObject



20
21
22
# File 'lib/perpetuity/postgres/date_value.rb', line 20

def to_s
  "'#{date.to_s}'::date"
end

#valueObject



24
25
26
# File 'lib/perpetuity/postgres/date_value.rb', line 24

def value
  date
end