Class: Vpim::Icalendar::Vtodo
- Inherits:
-
Object
- Object
- Vpim::Icalendar::Vtodo
- Includes:
- Property::Base, Property::Common, Property::Location, Property::Priority, Property::Recurrence, Property::Resources
- Defined in:
- lib/vpim/vtodo.rb
Class Method Summary collapse
-
.create(fields = []) ⇒ Object
Create a new Vtodo object.
Instance Method Summary collapse
-
#completed ⇒ Object
The date and time that a to-do was actually completed, a Time.
-
#due ⇒ Object
The date and time that a to-do is expected to be completed, a Time.
-
#fields ⇒ Object
TODO - derive everything from Icalendar::Component to get this kind of stuff?.
-
#initialize(fields) ⇒ Vtodo
constructor
:nodoc:.
-
#percent_complete ⇒ Object
The percentage completetion of the to-do, between 0 and 100.
-
#properties ⇒ Object
:nodoc:.
Methods included from Property::Recurrence
#occurrences, #occurs_in?, #rdates
Methods included from Property::Resources
Methods included from Property::Location
Methods included from Property::Priority
Methods included from Property::Common
#access_class, #attachments, #attendee?, #attendees, #categories, #comments, #contacts, #created, #description, #dtstamp, #dtstart, #lastmod, #organizer, #sequence, #status, #summary, #uid, #url
Methods included from Property::Base
#propinteger, #proptext, #proptextarray, #proptextlistarray, #proptime, #proptoken, #propvalue, #propvaluearray
Constructor Details
#initialize(fields) ⇒ Vtodo
:nodoc:
31 32 33 34 35 36 37 |
# File 'lib/vpim/vtodo.rb', line 31 def initialize(fields) #:nodoc: outer, inner = Vpim.outer_inner(fields) @properties = Vpim::DirectoryInfo.create(outer) @elements = inner end |
Class Method Details
.create(fields = []) ⇒ Object
Create a new Vtodo object.
If specified, fields
must be either an array of Field objects to add, or a Hash of String names to values that will be used to build Field objects. The latter is a convenient short-cut allowing the Field objects to be created for you when called like:
Vtodo.create('SUMMARY' => "buy mangos")
TODO - maybe todos are usually created in a particular way? I can make it easier. Ideally, I would like to make it hard to encode an invalid Event.
63 64 65 66 67 68 69 |
# File 'lib/vpim/vtodo.rb', line 63 def Vtodo.create(fields=[]) di = DirectoryInfo.create([], 'VTODO') Vpim::DirectoryInfo::Field.create_array(fields).each { |f| di.push_unique f } new(di.to_a) end |
Instance Method Details
#completed ⇒ Object
The date and time that a to-do was actually completed, a Time.
77 78 79 |
# File 'lib/vpim/vtodo.rb', line 77 def completed proptime 'COMPLETED' end |
#due ⇒ Object
The date and time that a to-do is expected to be completed, a Time.
72 73 74 |
# File 'lib/vpim/vtodo.rb', line 72 def due proptime 'DUE' end |
#fields ⇒ Object
TODO - derive everything from Icalendar::Component to get this kind of stuff?
40 41 42 43 44 45 |
# File 'lib/vpim/vtodo.rb', line 40 def fields #:nodoc: f = @properties.to_a last = f.pop f.push @elements f.push last end |
#percent_complete ⇒ Object
The percentage completetion of the to-do, between 0 and 100. 0 means it hasn’t started, 100 that it has been completed.
TODO - the handling of this property isn’t tied to either COMPLETED: or STATUS:, but perhaps it should be?
86 87 88 |
# File 'lib/vpim/vtodo.rb', line 86 def percent_complete propinteger 'PERCENT-COMPLETE' end |
#properties ⇒ Object
:nodoc:
47 48 49 |
# File 'lib/vpim/vtodo.rb', line 47 def properties #:nodoc: @properties end |