Class: Vcard::V3_0::PropertyValue::Time

Inherits:
Vobject::PropertyValue show all
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) ⇒ Time

Returns a new instance of Time.



230
231
232
233
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 230

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

Instance Method Details

#to_hashObject



245
246
247
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 245

def to_hash
  value
end

#to_sObject



235
236
237
238
239
240
241
242
243
# File 'lib/vobject/vcard/v3_0/propertyvalue.rb', line 235

def to_s
  ret = "#{value[:hour]}:#{value[:min]}:#{value[:sec]}"
  ret = ret + ".#{value[:secfrac]}" if value[:secfrac]
  zone = ""
  zone = "Z" if value[:zone] && value[:zone] == "Z"
  zone = "#{value[:zone][:sign]}#{value[:zone][:hour]}:#{value[:zone][:min]}" if value[:zone] && value[:zone].is_a?(Hash)
  ret = ret + zone
  ret
end