Class: Vcard::V3_0::PropertyValue::Date

Inherits:
Vobject::PropertyValue show all
Includes:
Comparable
Defined in:
lib/vobject/vcard/v3_0/propertyvalue.rb

Instance Attribute Summary

Attributes inherited from Vobject::PropertyValue

#errors, #norm, #type, #value

Instance Method Summary collapse

Methods inherited from Vobject::PropertyValue

#name, #to_norm

Constructor Details

#initialize(val) ⇒ Date

Returns a new instance of Date.



166
167
168
169
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 166

def initialize(val)
  self.value = val
  self.type = "date"
end

Instance Method Details

#<=>(another) ⇒ Object



162
163
164
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 162

def <=>(another)
  value <=> another.value
end

#to_hashObject



175
176
177
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 175

def to_hash
  value
end

#to_sObject



171
172
173
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 171

def to_s
  sprintf("%04d-%02d-%02d", value[:year].to_i, value[:month].to_i, value[:day].to_i)
end