Class: Everdone::TodoItem
- Inherits:
-
Object
- Object
- Everdone::TodoItem
- Defined in:
- lib/everdone/todoItem.rb
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#due_date ⇒ Object
readonly
Returns the value of attribute due_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#project_ids ⇒ Object
readonly
Returns the value of attribute project_ids.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #clean_title ⇒ Object
- #get_label_url(label) ⇒ Object
- #get_project_url(project_index) ⇒ Object
-
#initialize(config, todoist_item, projects, labels) ⇒ TodoItem
constructor
A new instance of TodoItem.
Constructor Details
#initialize(config, todoist_item, projects, labels) ⇒ TodoItem
Returns a new instance of TodoItem.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/everdone/todoItem.rb', line 20 def initialize(config, todoist_item, projects, labels) @config = config item = todoist_item @id = item['id'] @title = item['content'] clean_title() # strip off all (known) Todoist detritus @created = item['completed_date'] @projects = [] # Just the parent for now. TODO: array of projects starting with senior parent and working down to immediate parent @projects.push(projects[item['project_id']]) @project_ids = [] # Just the parent for now. TODO: array of project ids starting with senior... (see above) @project_ids.push(item['project_id']) @labels = [] # arrary of associated labels (random order) if not item['labels'].nil? item['labels'].each { |labelId| @labels.push(labels[labelId]) } end @priority = item['priority'] @due_date = item['due_date'] @notes = [] # array of notes if not item['notes'].nil? item['notes'].each { |note| new_note = TodoNote.new(note) @notes.push(new_note) } end end |
Instance Attribute Details
#created ⇒ Object (readonly)
Returns the value of attribute created.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def created @created end |
#due_date ⇒ Object (readonly)
Returns the value of attribute due_date.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def due_date @due_date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def id @id end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def labels @labels end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def notes @notes end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def priority @priority end |
#project_ids ⇒ Object (readonly)
Returns the value of attribute project_ids.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def project_ids @project_ids end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def projects @projects end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
19 20 21 |
# File 'lib/everdone/todoItem.rb', line 19 def title @title end |
Instance Method Details
#clean_title ⇒ Object
48 49 50 51 |
# File 'lib/everdone/todoItem.rb', line 48 def clean_title() cleaned_title = @title.match(@config.todoist_link_title_regex) @title = cleaned_title.nil? ? @title : cleaned_title[1].strip end |
#get_label_url(label) ⇒ Object
57 58 59 |
# File 'lib/everdone/todoItem.rb', line 57 def get_label_url(label) return @config.todoist_label_url + label end |
#get_project_url(project_index) ⇒ Object
53 54 55 |
# File 'lib/everdone/todoItem.rb', line 53 def get_project_url(project_index) return @config.todoist_project_url + @project_ids[project_index].to_s end |