Class: Vobject::Vcalendar::PropertyValue::Duration

Inherits:
PropertyValue
  • Object
show all
Defined in:
lib/vobject/vcalendar/propertyvalue.rb

Instance Attribute Summary

Attributes inherited from PropertyValue

#errors, #norm, #type, #value

Instance Method Summary collapse

Methods inherited from PropertyValue

#<=>, #name, #to_norm

Constructor Details

#initialize(val) ⇒ Duration

Returns a new instance of Duration.



352
353
354
355
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 352

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

Instance Method Details

#to_hashObject



369
370
371
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 369

def to_hash
  value
end

#to_sObject



357
358
359
360
361
362
363
364
365
366
367
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 357

def to_s
  ret = "P"
  ret = value[:sign] + ret if value[:sign]
  ret = ret + "#{value[:weeks]}W" if value[:weeks]
  ret = ret + "#{value[:days]}D" if value[:days]
  ret = ret + "T" if value[:hours] || value[:minutes] || value[:seconds]
  ret = ret + "#{value[:hours]}H" if value[:hours]
  ret = ret + "#{value[:minutes]}M" if value[:minutes]
  ret = ret + "#{value[:seconds]}S" if value[:seconds]
  ret
end