Class: Todoist::Task
- Inherits:
-
Struct
- Object
- Struct
- Todoist::Task
- Includes:
- StructCleanup
- Defined in:
- lib/todoist/task.rb
Instance Attribute Summary collapse
-
#added_at ⇒ Object
Returns the value of attribute added_at.
-
#added_by_uid ⇒ Object
Returns the value of attribute added_by_uid.
-
#assigned_by_uid ⇒ Object
Returns the value of attribute assigned_by_uid.
-
#checked ⇒ Object
Returns the value of attribute checked.
-
#child_order ⇒ Object
Returns the value of attribute child_order.
-
#completed_at ⇒ Object
Returns the value of attribute completed_at.
-
#content ⇒ Object
Returns the value of attribute content.
-
#day_order ⇒ Object
Returns the value of attribute day_order.
-
#deadline ⇒ Object
Returns the value of attribute deadline.
-
#description ⇒ Object
Returns the value of attribute description.
-
#due ⇒ Object
Returns the value of attribute due.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_collapsed ⇒ Object
Returns the value of attribute is_collapsed.
-
#is_deleted ⇒ Object
Returns the value of attribute is_deleted.
-
#jsw_ignored_keys ⇒ Object
Returns the value of attribute jsw_ignored_keys.
-
#jsw_properties ⇒ Object
Returns the value of attribute jsw_properties.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#note_count ⇒ Object
Returns the value of attribute note_count.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
-
#responsible_uid ⇒ Object
Returns the value of attribute responsible_uid.
-
#section_id ⇒ Object
Returns the value of attribute section_id.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Instance Method Summary collapse
- #due_to_struct(args) ⇒ Object
- #get_properties(args) ⇒ Object
-
#initialize(*arg_hashes) ⇒ Task
constructor
A new instance of Task.
- #properties_string(properties = nil) ⇒ Object
- #to_h ⇒ Object
- #url ⇒ Object
Methods included from StructCleanup
#fields_to_date_time, #ignore_undefined_keys, #properties_to_desc, #replace_keys
Constructor Details
#initialize(*arg_hashes) ⇒ Task
Returns a new instance of Task.
34 35 36 37 38 39 40 41 |
# File 'lib/todoist/task.rb', line 34 def initialize(*arg_hashes) args = arg_hashes.first get_properties(args) fields_to_date_time(args, %w[added_at updated_at]) ignore_undefined_keys(args) due_to_struct(args) super end |
Instance Attribute Details
#added_at ⇒ Object
Returns the value of attribute added_at
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def added_at @added_at end |
#added_by_uid ⇒ Object
Returns the value of attribute added_by_uid
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def added_by_uid @added_by_uid end |
#assigned_by_uid ⇒ Object
Returns the value of attribute assigned_by_uid
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def assigned_by_uid @assigned_by_uid end |
#checked ⇒ Object
Returns the value of attribute checked
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def checked @checked end |
#child_order ⇒ Object
Returns the value of attribute child_order
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def child_order @child_order end |
#completed_at ⇒ Object
Returns the value of attribute completed_at
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def completed_at @completed_at end |
#content ⇒ Object
Returns the value of attribute content
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def content @content end |
#day_order ⇒ Object
Returns the value of attribute day_order
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def day_order @day_order end |
#deadline ⇒ Object
Returns the value of attribute deadline
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def deadline @deadline end |
#description ⇒ Object
Returns the value of attribute description
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def description @description end |
#due ⇒ Object
Returns the value of attribute due
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def due @due end |
#duration ⇒ Object
Returns the value of attribute duration
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def duration @duration end |
#id ⇒ Object
Returns the value of attribute id
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def id @id end |
#is_collapsed ⇒ Object
Returns the value of attribute is_collapsed
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def is_collapsed @is_collapsed end |
#is_deleted ⇒ Object
Returns the value of attribute is_deleted
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def is_deleted @is_deleted end |
#jsw_ignored_keys ⇒ Object
Returns the value of attribute jsw_ignored_keys
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def jsw_ignored_keys @jsw_ignored_keys end |
#jsw_properties ⇒ Object
Returns the value of attribute jsw_properties
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def jsw_properties @jsw_properties end |
#labels ⇒ Object
Returns the value of attribute labels
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def labels @labels end |
#note_count ⇒ Object
Returns the value of attribute note_count
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def note_count @note_count end |
#parent_id ⇒ Object
Returns the value of attribute parent_id
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def parent_id @parent_id end |
#priority ⇒ Object
Returns the value of attribute priority
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def priority @priority end |
#project_id ⇒ Object
Returns the value of attribute project_id
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def project_id @project_id end |
#project_name ⇒ Object
Returns the value of attribute project_name
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def project_name @project_name end |
#responsible_uid ⇒ Object
Returns the value of attribute responsible_uid
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def responsible_uid @responsible_uid end |
#section_id ⇒ Object
Returns the value of attribute section_id
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def section_id @section_id end |
#updated_at ⇒ Object
Returns the value of attribute updated_at
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def updated_at @updated_at end |
#user_id ⇒ Object
Returns the value of attribute user_id
2 3 4 |
# File 'lib/todoist/task.rb', line 2 def user_id @user_id end |
Instance Method Details
#due_to_struct(args) ⇒ Object
43 44 45 |
# File 'lib/todoist/task.rb', line 43 def due_to_struct(args) args["due"] = Due[args["due"]] end |
#get_properties(args) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/todoist/task.rb', line 56 def get_properties(args) args[:jsw_properties] = {} if (jsw_properties_match = args["description"].match(/(.*)```\s*~~~begin_yaml~~~\s*(.*)\s*~~~end_yaml~~~\s*```(.*)/m)) @desc = [jsw_properties_match[1], jsw_properties_match[3]] args[:jsw_properties] = YAML.safe_load(jsw_properties_match[2]) if args[:jsw_properties].is_a?(Hash) args[:jsw_properties].deep_symbolize_keys! end end end |
#properties_string(properties = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/todoist/task.rb', line 67 def properties_string(properties = nil) properties ||= jsw_properties <<~HEREDOC #{@desc&.dig(0)} ``` ~~~begin_yaml~~~ #{properties.to_yaml}~~~end_yaml~~~ ``` #{@desc&.dig(1)} HEREDOC end |
#to_h ⇒ Object
47 48 49 50 |
# File 'lib/todoist/task.rb', line 47 def to_h self.due = due.to_h super end |
#url ⇒ Object
52 53 54 |
# File 'lib/todoist/task.rb', line 52 def url "https://todoist.com/showTask?id=#{id}" end |